Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do push notifications on the iPhone determine which users are notified?

I'm just trying to understand push notification more.

Let's say I have a web service that my app connects to that needs a user to sign in with a username and password. And this all works fine when running the app.

Now... how does the web service determine which user to send the push notification to?

I'm really unsure on how it works with users with usernames and passwords. It would be great if someone could enlighten me to this. A better understanding could improve my apps in the future. Thanks!

like image 332
Popeye Avatar asked Dec 02 '22 23:12

Popeye


2 Answers

I'll give a brief over view of how push notifications work:

First, your app will call the registerForRemoteNotificationTypes: method. This will check that your app is allowed to send and receive the types of notifications you requested, and contact Apple's servers to register your device. You will get back a special token used to uniquely identify the device.

Your app needs to send this token to your server along with the details of the account that the user is logged in with, so your server can associate that token with the user.

When you want to send a push notification to a user, you lookup the token you received previously for that user and use that when sending the notification to Apple's server. This will forward the notification to the appropriate device.

It's probably a good idea if you read the Apple documentation here: Apple Push Notification Service. This will give you a clearer understand of how it all works.

like image 53
Mike Weller Avatar answered Dec 04 '22 11:12

Mike Weller


Here is the wonderful tutorial explains in detail, http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12

like image 32
Vignesh Avatar answered Dec 04 '22 11:12

Vignesh