2

I haver read this post to:

Apple Push Notifications to specific Users

I need to send push to specific devices, but my problem is that users that log into my app, are identified by a generated UDID, not using the deprecated UIDevice. I see that easyAPNS stores this values into the MySQL:

CREATE TABLE `apns_device_history` (
2
  `pid` int(9) unsigned NOT NULL auto_increment,
3
  `appname` varchar(255) NOT NULL,
4
  `appversion` varchar(25) default NULL,
5
  `deviceuid` char(40) NOT NULL,
6
  `devicetoken` char(64) NOT NULL,
7
  `devicename` varchar(255) NOT NULL,
8
  `devicemodel` varchar(100) NOT NULL,
9
  `deviceversion` varchar(25) NOT NULL,

I don't know how to link registered app users with this table, in order to achieve to send push to specific user. Is it possible to get by code user pid or device token?

Many thanks!

Community
  • 1
  • 1
theomen
  • 913
  • 3
  • 20
  • 39

1 Answers1

3

Developing any level of an APNS can be quite an undertaking unless you have a lot of knowledge into what is involved on both a server side and client side perspective.

Things to keep in mind:

  1. Server side must take into consideration that device identifiers (tokens) will change on each device if they update or restore their device - or even get a new device!
  2. Client side must take into consideration the delegate methods that must be implemented into the App Delegate to properly accept and handle these push notifications, as well as begin initiating them. (examples follow below).
  3. Server again must realize that you can get your push notification certificate black-listed if you don't set up a proper "feedback" service. What this does is check if that identifier exists, and if not then you take it out of your database so you don't continue trying to send push notifications to that user again.
  4. On the server you can either send one notification at a time (with time in between each individual one) or queue them up into a mass amount and "stream" these notifications. Really you MUST follow this or again you can be black-listed and won't be able to send push notifications to your users again.

Those 4 points really need to be understood before we begin any undertaking of creating any sort of push notification server.

id (int)
token (int - 32 length)
dateChanged (dateTime)

The three listed fields are really all you need for a basic push notification server. Personal identification in your database, the token for the device entry so you know who will receive the push message, and the dateChanged is optional but good to know how long you've had this in your database for.

Going back to the concept of "streaming" push notifications - you should really look into how to send multiple notifications at once with a basic PHP script (I've done an entire server in PHP with less than 100 lines of code, so it can be pretty simple with class based PHP).

CODE:

Unfortunately it would take up a lot of space to put all the code necessary for a basic push service but I highly recommend looking into the points I've mentioned above as well some pretty amazing tutorials for this task listed below:

Brayden
  • 1,795
  • 14
  • 20