chriscoder chriscoder - 3 months ago 22
iOS Question

how to send rich push to APNS

I can send a regular push just fine but cannot figure out to send a "rich" push. I've read Apples "Local and Push Notification Programming Guide" 5 times and it makes no mention of sending anything other than an alert, badge and sound. I cannot find any documentation for rich push in the developer center.

I must be looking for the wrong thing, maybe someone else has been down this road already?


You won't send a whole HTML content directly in your notification, but you can send "rich push" in the sense that you can send additional data in your Push Notifications, and not just alert, badge and sound: you can send any other key you want/need. (just put them outside of the aps entry of your JSON, like at the root of the JSON object).

Only limitation is that you are limited to 255 characters, so that's not designed to provide sthg like a large HTML file for example. Just to provide some additional keys of your choice, like for example an URL, some fields to describe internal ids of objects you want to display, etc.

Everything is described here in the Local and Push Notifications Programming Guide: look at the paragraph called "Examples of JSON Payloads", where they add dummy parameters like "acme1" and "acme2".

So applied to your case your could have a payload like that for your Push notification:

    "aps" : { "alert" : "Message received from Bob" },
    "rich-text-url" : "http://yourserver/message/1234"
    "id-of-object-to-show" : 456

The only thing to keep in mind is the 255 characters limit.
(Note: obviously the descriptive keys in my example above are only for explanation but one generally choose shorter key names like url and id instead to shorten the overall payload)