Introduction
Authorize and Revoke push tokens for the Apple and Google push notification services.
NOTE: PubNub's Mobile Push Notifications feature now support APNs HTTP/2 and this support involves different API calls and different publish payloads.
The type
parameter indicates the backend which PubNub will utilize:
apns
- Apple Push Notification service
gcm
- Firebase Cloud Messaging push notification service
Publishing
Given a channel myChannel
, and subscribed mobile clients, a server SDK must execute a public commend by sending the following JSON payload to myChannel
APNs HTTP/2 example:
{ "pn_apns": { "aps": { "alert": "hello world" }, "pn_push": [ { "targets": [ { "environment": "production", "topic": "BUNDLE_ID_FOR_APP_1" } ], "version": "v2" } ] } }
Non-APNs HTTP/2 example:
{ "pn_apns": { "aps": { "alert": "hi", "badge": 2, "sound": "melody" }, "pn_other": { "additional": "fields" } } }
{ "pn_gcm": { }, "pn_other": { "additional": "fields" } }
Please refer to the tutorial for additional examples.