You have implemented mobile push notifications into your PubNub application or you have made some changes (new push cert, for example) and now you are having some issues sending/receiving mobile push notifications. Maybe it's missing messages on client devices, getting duplicate messages, getting messages meant for another user/device. Whatever it is, we will provide the best tools and techniques for finding the root cause and resolving, or at least just getting all the necessary data points to send to PubNub Support to assist with troubleshooting.

Before you troubleshoot

Before you start getting your hands dirty with troubleshooting, think about the issue you are having and the probable root causes are. 

  • iOS: If you uploaded a new push certificate for your iOS app and users stopped getting push notifications, then this means that the users' push registration tokens have been invalidated (by Apple/APNS, not PubNub) 
    • It could be that your app is not asking APNS for the push registration token when the app starts (didFinishLoadingWithOptions gets invoked), as per Apple Push Notification best practices.
    • Or possibly you selected the wrong Environment setting (Development vs Production) for the push certificate.
      NOTE: please be sure to explicitly set this field and verify that it was persisted properly refreshing the screen after you click Save.
    • Be sure that you passing the device push token as an NSData datatype and not converting it to a string. 
  • Android: If you are not seeing GCM/FCM messages displayed
    • perhaps you are sending the wrong type of message (data vs notification). Please review KB article, Why are my FCM push notifications not working?
    • Make sure you have entered the proper Server or API keys for your PubNub key set's FCM/GCM configuration.

There may be other factors that may be suddenly causing you issues with your push mobile notifications so think through your implementations and configurations that might be the root cause.

The -pndebug Channel

You can do some high level debugging using the channel’s -pndebug channel and checking to see if the device is still registered to the channel. Messages from -pndebug come from the APNS and GCM services (from Apple and Google, not PubNub). Here are the steps:

  1. Use the PubNub Debug Console ( to subscribe to the channel’s -pndebug channel. If the channel you are publishing to is foo, then subscribe to foo-pndebug. Make sure you use the right pub/sub keys.

  2. Add "pn_debug":true to your message payload at the top level.

         "pn_gcm": { "data": { "message": "hello" } }, 
         "pn_apns": { "aps": { "alert": "hello" } }, 
         "pn_debug": true 

  3. Publish the message to channel foo, not to the channel's -pndebug channel. You can publish from your client or server application or from another instance of Debug Console (again, make sure you use the same pub/sub keys). You should see useful error messages in the Debug Console where you are subscribing to foo-pndebug, if there are any problems with the push message registration.

Sample Output

Successful Devices

The following message shows how many devices successfully received the push notification that were registered for push messages on the target channel for each push service.

Devices found for push notification apns: 2 gcm: 3 mpns: 0

Error, Warning and Info Messages

The following messages are examples of the types of messages that GCM and APNS push services can send back to PubNub's mobile push notification gateway servers.

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

All of the above messages can be sent to your server using PubNub's Mobile Push Gateway web hooks. A web hook is a URL (that you can have us configure on your keys) to a REST endpoint on your server. As messages come back to PubNub from the mobile push notification services, PubNub will relay them onto your REST endpoint for you to log and process as you require. Contact PubNub Support to request this configuration for your keys.

Check Channel Registration

You can also check to see if the device is still registered to the channel after you publish the push notification using a simple REST URL in the browser.

  • where push_type is either gcm or apns
  • and device_reg_token is the device's registration token

This will return all channels the device is still registered for push notification for the push type provided.

Example of response:


If that list comes back empty then there was likely a device registration token issue (invalid token or device not registered, for example). This might happen because the device token was reported as invalid by the push notification services (APNS or GCM) and PubNub in turn unregisters that device token from all channels. But the -pndebug channel should reveal the reason for this to you.

Test Push Notifications Without PubNub

Most times it is not PubNub that is causing the push notification issues. Often it is an invalid registration token (APNS or GCM) or a device with two valid registration tokens (yes, it can actually happen) or the push service cert or key is no longer valid. Testing push notifications without PubNub getting involved is the best way to eliminate, or hone in on, the area of probable fault.

Testing GCM

There are a few good online tools for testing GCM push notifications and one native Mac app.

Mac App Store

Online Web Apps

Testing APNS

For APNS, you can run a simple Python script that uses your push certificate (.pem file) to verify that the certificate is valid. And optionally, you can specify a device registration token to which test push notifications will be sent. See our knowledge base article, How Do I Test My PEM Key, for full details.

For more rich UI/UX tools, you can find APNS test apps for the Mac (in the App Store) as well as online web apps:

Mac App Store

Online Web Apps

See also: 


If all of the above fails to reveal the root cause and probable solution to your push notification challenges, you can contact PubNub Support providing them with any information you have collected using all of the above methods.