Skygear Push Basics
You need to register the devices before sending them push notifications.
It is suggested that you register a device with remote server on every launch. Since the container remembers the device ID when the device is registered on the remote server, it will reuse an existing device ID whenever you try to register the current device.
You should also request a remote notification token at some point in the program. If it is appropriate to ask the user for permission for remote notification, you can also do so when the application launches.
When a device token is registered with Apple Push Notification Service, you should register the device once again by updating the registration with a device token.
When the device is registered on the remote server, a device ID will be
available to the client application. If you register the current device
using the above convenient methods, the device ID is returned from
registeredDeviceID property on the container.
Send push notification from cloud code
To send push notifications through cloud code, please refer to the Cloud Code Guide: Push Notifications.
Sending push notification to users
Sending push notification to devices
When a device is registered, it is associated with the authenticated user. Therefore it is necessary to unregister the device when the user is no longer associated with the device, for example when the user logs out.
TODO: Problems with the interface
- There are no exported interfaces for SDK to fetch device ids. Sending to device is basically unusable.
- Cannot really think of a valid use case to send notification from one device to another device. Sending to devices is more of a plugin thing: e.g. send notification to devices that have an outdated version of app.
- The first array argument of
sendCompletionHandleris always of
NSStringIn the case of sending to users, it would be expected to be an array of