iOS Push Notifications && device identification

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi all,
currently working on push notifications.
I want to send push notifications to users, but I'm facing 2 little problems.

1) How can I send push notification to ALL users of my app?

2) How can I identify a device? Because I store tokens into database, and update if needed, but then I need a unique number. To know which record to update.

Ofcourse I can generate some number, store locally on device and hope its 100% unique. like random(1000) * timestamp
Code:
[[NSUUID UUID] UUIDString]
gives me a different result every time.
 
Last edited:

TheWatchfulOne

macrumors 6502
Jun 19, 2009
416
310
Can you be more specific?

Do you want to send local notifications or remote notifications?

What do you have that would prevent some users from receiving notifications while allowing others to receive notifications? Other than the fact that users can opt out of receiving notifications.

What kind of info will the notifications contain? Knowing this would help somebody to know how to help you with regard to how and/or when to send them.

It used to be that developers could use UDID to identify a specific device but that is now not allowed. How specifically do you want to identify the device? Do you want to distinguish iPhones from iPads or do you want to distinguish one iPhone from another of the same model and generation?
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi TheWatchFullOne,

Eventually Im going to send remote and local notifications, but for now only remote.

These notifications will contain different messages. Its to notify the users that do want to receive notifications about new events that coming up. (Its for an app for concert events company)

The thing is I want to know difference of the devices. Once a device's token is changed, i dont want to keep the old token but update the old one.

About sending it to all users, i could write a loop that will go through all tokens and send it one by one, but I think it should be able to simply send it to all users in one go.

Is it also possible to link a notification to a specific view? When you click on my notification it will go to the main view of the app. I would like to have it to go to the view where this new event is described.

Thanks for any help!
 

dejo

Moderator
Staff member
Sep 2, 2004
15,981
450
The Centennial State
The thing is I want to know difference of the devices. Once a device's token is changed, i dont want to keep the old token but update the old one.

About sending it to all users, i could write a loop that will go through all tokens and send it one by one, but I think it should be able to simply send it to all users in one go.

Is it also possible to link a notification to a specific view? When you click on my notification it will go to the main view of the app. I would like to have it to go to the view where this new event is described.
The Local and Remote Notification Programming Guide talks about these things:

Connect regularly with the feedback service and fetch the current list of those devices that have repeatedly reported failed-delivery attempts. Then stop sending notifications to the devices associated with those applications.
If you need to send a large number of push notifications, spread them out over connections to several different gateways.
A notification is a short message consisting of two major pieces of data: the device token and the payload. ... The payload is a JSON-defined property list that specifies how the user of an application on a device is to be alerted.
Make sure you've read the whole thing and then come back here with specific questions, if you don't understand something.
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi dejo

Thanks for pointing to the documentation.
I understand the part about sending big amount of notifications, however I only have 1 webserver, and dont know how to send through multiple gateways. I will be sending the notifications with a delay between each token.

Then still I cant find any way to get a static unique number from an device. I guess generating a unique number and storing locally will be the only solution for me.

Pointing to failing notification multiple times to the advice to remove the token from the database is an good idea.

I only got one more question left

The didReceiveRemoteNotification, is that being triggered when it actually receives it?
I would like to tray to fetch content of the notification where the user clicks on, so by parsing that content I could be able to redirect to the viewcontroller I want the user to see when they click on it.

Any idea's?
 

dejo

Moderator
Staff member
Sep 2, 2004
15,981
450
The Centennial State
The didReceiveRemoteNotification, is that being triggered when it actually receives it?
Yes! Try it and see!

I would like to tray to fetch content of the notification where the user clicks on, so by parsing that content I could be able to redirect to the viewcontroller I want the user to see when they click on it.

Any idea's?
Look at the userInfo NSDictionary that is passed in this method.
 

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Yes! Try it and see!



Look at the userInfo NSDictionary that is passed in this method.
I will :)

Thanks for the tips and hints ;-)
I guess I will be able to trigger different actions with
Code:
application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
and the Item ID of the framedata from the notification :)

Thanks again!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.