Check push device registration

This guide shows you how to confirm whether a specific device token is still registered on the channels you expect. It uses a REST call, part of Mobile Push Notifications. Firebase Cloud Messaging (FCM) and Apple Push Notification service (APNs) registrations use different endpoints, so send the request that matches how the device registered, over HTTPS.

Check an FCM device registration​

Send a GET request to the v1 devices endpoint with type=fcm:

1curl 'https://ps.pndsn.com/v1/push/sub-key/{sub_key}/devices/{device_token}?type=fcm&uuid={user_id}'
  • {sub_key}: your app's subscribe key.
  • {device_token}: the FCM registration token you want to check.
  • {user_id}: the User ID making the request.

If Access Manager is enabled on the keyset, also add the parameters in Authorize the request.

Check an APNs2 device registration​

Devices registered with the apns2 push type use the v2 devices-apns2 endpoint, not the v1 devices endpoint. Send a GET request with the APNs environment and topic:

1curl 'https://ps.pndsn.com/v2/push/sub-key/{sub_key}/devices-apns2/{device_token}?environment={environment}&topic={topic}&uuid={user_id}'
  • {sub_key}: your app's subscribe key.
  • {device_token}: the APNs device token you want to check.
  • {environment}: development or production. Use the same value the app used when it registered the device. A build installed by Xcode gets a development device token, and a TestFlight or App Store build gets a production one.
  • {topic}: the app's bundle identifier, for example com.yourcompany.yourapp. Use the same value the app used when it registered the device.
  • {user_id}: the User ID making the request.

If Access Manager is enabled on the keyset, also add the parameters in Authorize the request.

Authorize the request​

If Access Manager is enabled on the keyset, add a token to either request with the auth query parameter:

1curl 'https://ps.pndsn.com/v2/push/sub-key/{sub_key}/devices-apns2/{device_token}?environment={environment}&topic={topic}&uuid={user_id}&auth={token}'

{token} is an Access Manager token your server granted for this User ID. Listing a device's channels doesn't need a channel permission, but PubNub still checks that the token is valid and belongs to this User ID. An invalid token returns 403. Append &auth={token} to the FCM request the same way. A server that holds the secret key can instead sign the request with the signature and timestamp parameters. See Initialize a server SDK with a secret key. Keep the secret key on your server.

Read the response​

Both endpoints return a list of the channels the device is registered on for that push type:

1["channel1", "channel2", "channel3"]

If the device is registered on many channels, the response is paginated. Pass start with the last channel from the previous response, and count for the page size.

If the list contains the channels you expect, the device is correctly registered and push delivery issues lie elsewhere, for example in the payload. See Check the FCM payload if you're sending through FCM.

If the APNs2 list is empty, first confirm that environment and topic match the values the app registered with. If they match, or the FCM list is empty, the device token is likely invalid or no longer registered. APNs or FCM may have marked the token invalid, and PubNub unregistered it from every channel. This call only confirms the device's current registration state. To find out why the token became invalid, see Debug push notification messages or Forward push errors and device removals to your endpoint.

Was this page useful?

Last updated on