Push tokens endpoints

Method HTTP request Description
Add token POST /push_tokens Register a device token
Remove token DELETE /push_tokens/:device_id Delete a push token

Add token

Register a device token to start receiving push notifications.

Parameters:

Name Type Description
token string The APNS or GCM device token to register
type string Either apns or gcm
device_id string A stable ID that identifies the device, from the OS. Only used to avoid duplicate tokens for a device
apns_bundle_id string (optional) APNS bundle ID corresponding to the token
gcm_sender_id string (optional) GCM sender ID corresponding to the token
ios_version string (optional) Version number, such as 9.0. Determines how push payloads are sent, which changed in iOS 8. The new behavior, which allows larger payloads, is the default

HTTP request:

POST/push_tokens

Example:

{
    "token": "105ebe3fcb7e93efda22257caaf5b9c465043f6d0b2abf3bc8ae7c939655e949",
    "type": "apns",
    "device_id": "a7775566-bfbf-11e5-bf72-359a01002888",
    "apns_bundle_id": "com.layer.bundleid",
    "ios_version": "9.0"
}
curl -X POST \
     -H 'Accept: application/vnd.layer+json; version=3.0' \
     -H 'Authorization: Layer session-token="<TOKEN>"'' \
     -H 'Content-Type: application/json' \
     https://api.layer.com/push_tokens\
 -d '{"token":"105ebe3fcb7e93efda22257caaf5b9c465043f6d0b2abf3bc8ae7c939655e949","type":"apns","device_id":"a7775566-bfbf-11e5-bf72-359a01002888","apns_bundle_id":"com.layer.bundleid","ios_version":"9.0"}'

Possible responses:

Token registered successfully
Status: 202 (Accepted)
(Empty body)

Discussion

This endpoint is designed for mobile frameworks (React Native, Cordova, Titanium, etc) to register device tokens so that they can receive native push notifications.

Before registering tokens, you will need to setup push notifications with your respective platform(s).

Configure your APNS and/or FCM/GCM credentials in the Developer Dashboard. Select the Push link in the Developer Dashboard and follow the instructions to enable notifications for Android and/or iOS.

Note

Each user can have up to 25 push tokens, corresponding to 25 devices. If you attempt to register more than 25, the least recently used token will be unregistered in order to accommodate the new token. We may change this limit in the future.

Remove token

Deleting a push token stops push notification delivery to that device.

Parameters:

Name Type Description
device_id string The device_id provided when registering the token

HTTP request:

DELETE/push_tokens/:device_id

Example:

curl -X DELETE \
     -H 'Accept: application/vnd.layer+json; version=3.0' \
     -H 'Authorization: Layer session-token="<TOKEN>"'' \
     -H 'Content-Type: application/json' \
     https://api.layer.com/push_tokens/<device_id>

Possible responses:

Token deleted successfully
Status: 202 (Accepted)
(Empty body)