Debug push notification messages

This guide shows you how to diagnose why a push sent through Mobile Push Notifications isn't reaching a device. You do that by reading the errors FCM and APNs return to PubNub's mobile push gateway. Before you start, confirm:

  • Your publish and subscribe key pair has Mobile Push configured.
  • Your app is set up correctly in your iOS or Android developer account.
  • Your test payload contains the required push payload keys, such as pn_apns or pn_fcm.

Subscribe to the -pndebug companion channel, then publish the test message to the original channel. For continuous monitoring, forward push errors to your endpoint instead. To check whether a specific device token is still registered, see Check push device registration. To check whether an FCM payload uses the correct data or notification keys, see Check the FCM payload. To rule out PubNub entirely, see Test mobile push notifications externally.

Publish to the debug channel​

  1. Go to the PubNub Debug Console and subscribe to the channel named <your-channel>-pndebug. If you publish to foo, subscribe to foo-pndebug.

  2. Add "pn_debug": true to your message payload, at the top level, as a sibling of pn_fcm and pn_apns, not nested inside either of them:

    1{
    2 "pn_debug": true,
    3 "pn_fcm": {
    4 "data": {
    5 "message": "hello"
    6 }
    7 },
    8 "pn_apns": {
    9 "aps": {
    10 "alert": "hello"
    11 },
    12 "pn_push": [
    13 {
    14 "push_type": "alert",
    15 "auth_method": "token",
    show all 26 lines
  3. Publish the message to channel foo (not foo-pndebug). Publish from your client, your server, or the Debug Console itself. Debug messages arrive on foo-pndebug almost immediately.

Read the debug channel output​

Check the message count first. A successful delivery reports how many registered devices received the push on each provider:

1Devices found for push notification apns: 2 fcm

If a device or the whole push failed, look for an error message instead. These are examples of the responses FCM and APNs send back to PubNub's mobile push gateway:

1fcm Error: InvalidRegistration Devices: null
2fcm WARNING error: NotRegistered, sub_key: sub-c-..., channel: my_channel, reg_id: APA91bHRRxfHHB_T0AVojoJx..., timetoken: 14567269547473296
3apns INFO Certificate for sub-c-... valid (expiration: Sep 14 08:58:26 2016 GMT)
4apns ERROR Error on APNs send for subkey sub-c-... / channel gone_fishing / device 2a0a6234ffdb85df6624cf0546...: invalid token

If the publish call itself returns HTTP 400 Bad Request, read the text description in the response body. Common causes are an invalid type argument, a missing channels value, or an invalid device token.

Was this page useful?

Last updated on