Work with Channels

Adding Push Notifications Endpoints to Channel

If you want to provide your users with the ability to subscribe or opt out of some push notifications, you will need to subscribe devices to the corresponding channel(s). For example, you may have functional and marketing push notification channels.

There are two approaches how to use channels:

  • By default, a user is not subscribed to any channels. Then users subscribe to the channel(s) they want to receive pushes from. In this case, you need to invoke the Subscribe To Channel endpoint with those channels the user chose, e.g., "functional" and "marketing". Then while sending Push Notifications, select a channel to which you want to send the notification. Only devices subscribed to this channel will receive notifications:
926
  • By default, a user is subscribed to all channels. Then the user can opt out of some of them. In this case, you also need to invoke the Subscribe To Channel endpoint, but in this case, they should be named differently, like "opt-out-functional" and "opt-out-marketing." Then, while sending Push Notifications, create a filter that will remove from the list all devices that opt out of the channel:
922

Subscribe to Channel

To subscribe a device to the channel(s), send the PUT request to the corresponding URL:

curl -X PUT \
-H "Content-Type: application/json" \
-H "X-Appery-App-Id: <appGUID>" \
https://api.appery.io/rest/push/reg/<deviceID>/channel/<channel_name>

where:

  • deviceID is the unique device identifier
  • appGUID is the unique identifier of the Appery.io application
  • channel_name is the name of a channel to subscribe to.

Returns HTTP 200 OK status and device info if the specified device was subscribed to a specified channel and it doesn't matter if the device was subscribed to some of them earlier

HTTP StatusCodeDescription
400PNCA002App Id not specified
404PNCA006Device ID: not found
400PNCA015Project GUID: not found
400PNCA960Specified brand is not valid

Unsubscribe from Channel

To unsubscribe a device from the channel(s), send the DELETE request to the corresponding URL:

curl -X DELETE \
-H "Content-Type: application/json" \
-H "X-Appery-App-Id: <appGUID>" \
https://api.appery.io/rest/push/reg/<deviceID>/channel/<channel_name>

where:

  • deviceID is the unique device identifier
  • appGUID is the unique identifier of the Appery.io application
  • channel_name is the name of the channel to unsubscribe from.
    Returns HTTP 200 OK status if the specified device was unsubscribed from the specified channel and it doesn't matter if the device wasn't subscribed to some of them earlier.
HTTP StatusCodeDescription
400PNCR002App ID not specified
404PNCR006Device ID: not found
400PNCR015Project GUID: not found
400PNCR960Specified brand is not valid