Facebook chat in iPhone app with push notifications - iphone

We're planning an app which, among other things, is supposed to integrate a facebook chat.
We're discussing about the push notifications for receiving messages while the app's in background. What comes to mind is a proxy server for the chat, that'd actually connect to the facebook chat, and the iPhone app would connect to the proxy.
Then, it's easy to have the proxy server act as a push notification server.
Is this the only way to go, or are we making this more complex than it needs to be?
Any input is appreciated. Thanks.

To do push notification (App is closed, user receive a message and an alert appear on the iPhone), that's the only way, because every app need an unique certificate to send push notifications. This mean that official Facebook servers can't push for third-party applications. You need a proxy that keep a connection open to FB and push alerts to Apple's Push Notification Server when needed.
Inside the app, instead, you can connect directly by opening a socket to Facebook's servers and use a Jabber library for ObjC. This allows another approach: Local Notifications. They're similar to Push, but they doesn't need a proxy server: it's the application running on user's device that keep an open connection (even when the app is in background) with Chat Server.
This is the documentation that covers both type of notification: Local and Push Notification Programming Guide

Facebook's chat system is a Jabber server, so I think you are making it more complex than you need to.

Related

apple push notification with iPhone

I would like to ask some suggestions to the experts who have faced similar problem as mine.
I am developing an iPhone application almost like a social networking application. This requires inviting friends to the application. The application is integrated with Facebook for login purpose. My question is that,
1) We can identify the Facebook friends who are using our application. We need to send notification (push notification) to iPhones of the friends who are using our application. Our backend is deployed in AWS. So that we have SNS and SQS for notification purpose. But it supports email and SMS notifications. I came to know from the web that there is Apple push notification services. Can we use apple push notification for this purpose? Which one is preferred here? SNS or apple push notification. Please advice. If you have any reference sites please give it to me.
To send APNS you need to have token of the device, so you can't send such notification just with the information about Facebook account. But if you are able to know that person is friend from Facebook and he uses your app, you can store some data, like token and facebook login of every user to send them APNS. But! Apple may reject it, because they hate when developers collect data that can identify a person.
APNS is nice for that situation, but risky. (Can anyone proof me wrong or right?)
Email is old-fashioned, but legal and easy to implement, i guess. Like, twitter sends push and email.
Also, you can use Facebook features (not so nice if you will integrate more social networks)
I think that you can use AWS SNS and APNS for what you want to do. You will need the pushTokens for the app/device that you are wanting to send push notifications as they act as the identifiers for the specific app/device to use as an endpoint.
You need to set up an SNS topic. Then you need to subscribe the devices (with the apps of interest) to the topic. Then you can publish to the topic (either programatically or via AWS Management console) and that message will propagate to all of the topics subscribed devices (termed endpoints).
AWS has a tutorial that walks you through this process: I have not tried it yet myself.
http://docs.aws.amazon.com/sns/latest/dg/mobile-push-apns.html

iPhone Push notifications via mobile safari

Is there a way to simulate push notifications by pushing data to mobile safari? Here are 2 scenarios.
I make a web app via phonegap and dont want to use APNS but rather make a web-socket connection and push data to the device myself. On the device end is there a "alert" function I can call to emulate a pop up when a user is not in the application?
Lets throw web app out the window. Is there a way I can do this in native mobile safari? Im not talking about a plain old JS alert window that would only come up if the user was in the app, but be able to do so with it backgrounded.
You cannot run background tasks with mobile safari so for #2 you can't do true push notifications or alerts. However you can send a user an SMS if you have the user's phone number. This can have a hyperlink to a part of your web site (which can contain some sort of payload). You can use a service such as Twilio to help you send SMS'es. However this costs money. APNS does not.
For scenario #1 I'm assuming you're talking about a native app using a phonegap solution. In this case when the app is backgrounded you cannot access any UI at all and wake up the app and show a UIAlert. In fact unless an app is registered for location updates or background music, the app is effectively not going to respond after a set period of time (it only can "finish" certain operations it had started before). So the websocket solution will only be effective if the user has the app opened.
You could register a local notification that runs at some predetermined time which will show an alert. But that is not being pushed from the server so its probably not what you want.
APNS is your best solution for scenario #1. Its not that hard to implement and its pretty inexpensive. Check out urban airship if you want to avoid building out your own server-side components for it.

Facebook push notification on my iphone app

i have developed facebook chat app for iphone using XMPP.
But the app can not get push notification from Facebook. How can i get push notification from Facebook on my application?
Rather than polling continuously, you should try to use Facebook's realtime updates API where applicable.
https://developers.facebook.com/docs/reference/api/realtime/
It's only applicable for certain kinds of content, but if it covers what you need, it'll be more efficient than polling like prasanna suggests.
Basically Facebook will send a request to a URL on your server whenever an event happens. The handler for that URL should then be responsible for sending the push notifications.
You can't bring Facebook to send a push notification to your app, you would have to set up a web server that continuously polls Facebook for changes and then sends a push notification to the iOS device when it detects a change.

iPhone: Is it possible to send Push-Notifications from a website?

I'd like to be notified of certain events on my webserver with a push notification from my website to my iPhone. Is this somehow possible, or do I have to install/create a special App for this?
In order to use Push Notification it would have to be a native iPhone app on your phone. You might be able to set up some sort of email notification coming from your website and turn on push notifications for your mail client on your iPhone.
In regards to #gnuf's post (Sorry it wouldn't let me comment on your post) Your web server can act as the Provider of Push Notifications but will still require a native application on the phone to receive the notifications.
You can definitely send notifications triggered from a website: you just have to hook up the backend to do so. See this previous post for more information.

Can an iphone application recieve push notifications from a custom server?

This is a very basic question on push notifications.
I need to know whether an iPhone application can receive push notifications.
I want them to operate as follows.
User installs the application.
When the application is not running, the user notices that something has changed with the application.
This is indicated by the application icon changing.
User opens the application and a new screen comes up that says:
"You have 3 new items to download"
The application will need to communicate with a custom server to obtain changes. The changes will only be known by that server, not the Apple App Store.
Is the above possible to program?
Yes. Your custom server sends them to Apple for distribution to devices. Read Apple's Push Notifications documentation for more info.