Could one iOS application support multiple push notification registration? - iphone

This is the first time that I approach the push notification service and I'm little bit confused. I 'd like to have just some conceptual help, not code.
I need to build an app that should receive and register for different kind of notifications. For instance in my app I'd like that users could register for PROMO notifications category and NEWS notifications category, I'd like that they could choose which one they want to be notified.
Reading the Apple doc, that was not so clear to me, it seems that once the app device is registered I receive just one token and seems impossible to receive more tokens for different kind of registration(NEWS and PROMO for instance), because the token is related to the app and the device. Is that correct?
The other thing that is not so clear to me is, if a device is registered for a specific notification is it possible to send the notification only to a set o devices?
If nothing of that is offered by Apple Push services do you think that is possible to manage everything like that:
-I register the app device for notification if (PROMO || NEWS) are selected
-I get the token
-I send the token to my server giving also as additional info about the service which the user wants to subscribe
-The server (provider) register the token and the kind of subscription (PROMO || NEWS)
-Later when I have a notification to push I ask the server all the tokens registered for that specific category and then I send the notification only to those devices registered for that category.
Thanks for helping me out I'm really confused.

"Reading the Apple doc, that was not so clear to me, it seems that once the app device is registered I receive just one token and seems impossible to receive more tokens for different kind of registration(NEWS and PROMO for instance), because the token is related to the app and the device. Is that correct?"
YES
The other thing that is not so clear to me is, if a device is registered for a specific notification is it possible to send the notification only to a set o devices?
YES, you need a DB where you connect a Push Token with the related Services (promo | news). If you have a new Promo Push Message you send the message to all related token. on the app site, everytime the user change the categorie (promo / news) you should prpvide these infos to your service with the push token.

These are all problems that you have to solve yourself on the server side. The push service simply provides a means to send a single message to a single device. You have to figure out yourself which messages you want to send to which devices. Each message has to be sent individually, there's no way to "broadcast" a message to all your users directly.
You could think of the push tokens as email addresses – of course, one email address might be subscribed to different newsletters from the same publisher, but it's the publisher's job (yours) to figure out whom to send which newsletters, not the email provider's (Apple's).

You should think of the push notification registration like my I send the user push notifications. Not what kind of push notification can I send the user.
Then you need to do serverside filtering on you categories, like the ones in your example promo and news.
The perferance of the user should be stored on your server, so you will know what kind of notification to send to which user.

Related

Send reminder notifications for user's birthday

I am creating an app using Swift and Parse as my backend platform. In my application a User can send an invitation to be connected to another user and as soon as they are connected the app should send notifications to remind the user about his friend’s birthday.
In this scenario I have two moments in which the app should send a notification:
1- When user A sends an invitation to user B, user B should receive a notification
2- When it’s user’s B birthday, user A should receive a notification and vice versa
I created a Parse object called AppNotification that is responsible for storing information about the notifications the user should receive. So when a user sends an invitation to another user I am adding a line in the AppNotification table, the same happens when it’s a birthday of a friend. Using this I can calculate the number of unread notifications and show it to the user in the UI using the components badge.
My question is more related to the best way to send the birthday notification. What I am considering is:
1- When user A sends and invitation to user B I have to send a push notification to user B.
2- As soon as the users are connected I can schedule local notifications to remind them about the birthday. This solution would use Local Notifications instead of Push Notifications.
3- Or create a Job in Parse that will be executed every day and will read all the users whose birthday is today and send a push notification to his friends. This solution would use Push notifications and I would not need to worry about scheduling local notifications.
Between the points 2 and 3 which one is the best solution? Is there any other approach I could use? When should I consider using Local Notifications other than Remote Notifications?
Thank you in advance.
Regarding points 2 and 3: there are pros and cons for both options: Having the reminders as local notifications is basically what your local calendar app does, i.e. you don't need a connection the Internet / Parse. However: what happens if one party (A) decides that she no longer wants to be a "friend" (of B)? Should notifications still be sent? If not, you could easily delete the scheduled notification on the server. This would also ensure that the other party (B) wouldn't receive notifications of a former friend (A) if she didn't open the app in the meantime and synced the list of friends.
There are of course more pros and cons, so it is really a matter of your preference and possibly other constraints (e.g. should an active internet connection be necessity?).

How can I send apple push notifications based on userIDs not only on device tokens?

I use push notifications in my iOS application but the problem is - several users with different IDs in the system can use the same device and I want to send push notification only to the user which is logged in, but now notifications arrive to the device even if other user is logged in. I know that APNS identifies pushes only by device tokens...
But is there some way to send push notifications based on user ID or other information not only device token?
You'll have to manage it yourself.
Whenever a user logs-in to your app, notify your server (send the user-id to the server).
Do the same whenever a user logs-off.
In your server, based on the currently logged-in user (you'll have to manage a database that contains for each device token the currently logged-in user), you can decide
which push notification to send to the device.
I don't think iOS push notification is right for your problem. here is why
consider you have an app with multiple users using the same device. you have a simple scenario where users can assign tasks to other users and they would like to get notifications when a task has been assigned to them
you do 'user to device token' mapping yourself on the server. consider user A and user B. both registered to receive notifications. so on the server both of them will have an entry in the mapping of what their device tokens are
Now, user B is logged out -- you will update on the server by removing the token for user B? or say use a flag to update the status that he is logged out?
user A now assigns a task to user B. on the server, you can see that user B has no mapping or mapping status is not active?
what happens to the notification?
you will end up queuing a notification for user b until he logs in? and push again? but again how do you know when to push again?
It is better you provide some UX in the app to get the notifications on a tap or periodically poll the server for any notifications

How to check if a person in your iPhone contact list has an app installed?

I want to allow people to privately share data with each other using their contacts list to select people to share with. I'm planning on using Push Notifications to notify others that they have been shared with, but how can I handle those that do not have the app installed?
The cases are that I have their phone # and/or email. I can simply send them a message saying "X wants to share Y with you", but how can I determine if I need to send a Push Notification or an email/text?
If you're looking for API then you're out of luck. You can always collect this personal data server-side with agreement of your users. There you can also manage groups and other community relations.
Check here:
https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html
The crux of it though will be that you will need to store a token when the device is registered anyway to be able to send notifications to them, so you can use that.
And using The Feedback Service alluded to in the documentation, you can remove the token, should it fail too often.
But, as rokjarc said, if you're expecting a third-party API to exist, you're pretty much out of luck. Apple ahs done most of the work for you already anyway.
When the app registeres for push notifications you need to pass additional data to your server. The user could input their own email/phone which will be sent to the server so that users can find each other. The email/phone can be stored alongside with the push token. When someone wants to share something, you would search the corresponding push token in the database and send the notification through APNS. Note there can be multiple push tokens for one email or phone i.e. when a user has multiple devices.
The users of your app should be aware of the data which is stored on your server and should have the option to delete it. Also use the APNS feedback service to detect and remove invalid push tokens.

Apple Push Notifications to specific Users

as far as I understand APN's I can only send them to the app not a specific user that uses my app.
Is there a way of sending APN's only to specific users that use my app? I can't think of a way of doing this...
Greetz
APNS is not a broadcast medium. As it says in the documentation:
Apple Push Notification service transports and routes a notification
from a given provider to a given device.
When you send a notification from the server, one of the paramters is the device ID.
Apple's Push Notifications are always sent to specific 'users' (a specific device being an iphone, ipad)
What you do when you want to use APN is register the application for push notifications. Then you get a token that links the user's device to the notification service. You then use this token to 'push notifications' to APN which will in turn send a notification to that device. Notifications are pushed by 'Providers'.
Here's apple's documentation on the matter: Apple Push Notifications
Look up 'Registering for Remote Notifications' to register the device
and 'Handling Local and Remote Notifications' to handle the incoming notifications.
Read up on how to send notifications here: Providers
It is possible. I use Easy APNS and in newMessage() you can specify the PID (saved in a MySQL database) of the user.
Have a look at http://www.easyapns.com/

Sending push notification from device to all contacts

I have an app where I would like to select a user in my contacts. If that person has my app installed, then I would like to send some data that is relevant for this app using a notification. The other user gets the notification, and acts on it within this app. Is that possible? I am thinking that if I can identify that users device, I can store this message in a server. When the user connects to the app, it will retrieve and get this users message from the server. But question is can I identify other devices like this, from my contact list. Can I send this notification using phone number instead of device id?
Please help.
Thank you,
Anks
No, you cannot. You have to have the Apple Push Token for a device and the user has to have notifications turned on to be able to receive notifications from Apple Push.
You would need to maintain a server side database linking the APNS Token to a specific user account. There are a lot of dots to connect with this kind of implmentation. Your better bet would be maintaining a "list of contacts" within your App to link contacts to.