PythonTornadoTornadoTwistedAsyncioNativePython-Tornado V4 Mobile Push API Reference for Realtime Apps

 

These docs are for PubNub 4.0 for Python-Tornado V4 which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Python, PubNub 3.0 for Python-Tornado and PubNub 3.0 for Python-Twisted.

If you have questions about the PubNub for Python SDK, please contact us at support@pubnub.com.

PubNub's Mobile Push Gateway feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android GCM (Google Cloud Messaging)/FCM (Firebase Cloud Messaging) and Apple iOS APNs (Apple Push Notification service).

By using the Mobile Push Gateway, developers can eliminate the need for developing, configuring, and maintaining additional server-side components for third-party push notification providers.

Learn more about our Mobile Push Gateway here.


Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
Enable push notifications on provided set of channels.
To run Adding Device to Channel you can use the following method(s) in the Python-Tornado V4 SDK:
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesn/aThe available push types. Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS, PNPushType.APNS2
    channelsListYesn/aThe channels to add the push notifications to.
    device_idStringYesn/aThe device ID (token) to associate with the push notifications.
    topicStringRequired for PNPushType.APNS2n/aThe topic name for the notification. For the Apple platform, this is the application's bundle identifier. Required only if push_type is set to PNPushType.APNS2.
    environmentStringRequired for PNPushType.APNS2PNPushEnvironment.DEVELOPMENTThe environment where the device should manage the list of channels with enabled notifications. Required only if push_type is set to PNPushType.APNS2.
from pubnub.enums import PNPushType

envelope = yield pubnub.add_channels_to_push()\
    .push_type(PNPushType.GCM)\
    .channels(["ch1", "ch2", "ch3"])\
    .device_id("deviceId")\
    .future()
The add_channels_to_push() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.is_error()

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
Request for all channels on which push notification has been enabled using specified pushToken.
To run Listing Channels For Device you can use the following method(s) in the Python-Tornado V4 SDK:
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesn/aThe available push types. Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS, PNPushType.APNS2
    device_idStringYesn/aThe device ID (token) to associate with the push notifications.
    topicStringRequired for PNPushType.APNS2n/aThe topic name for the notification. For the Apple platform, this is the application's bundle identifier. Required only if push_type is set to PNPushType.APNS2.
    environmentStringRequired for PNPushType.APNS2PNPushEnvironment.DEVELOPMENTThe environment where the device should manage the list of channels with enabled notifications. Required only if push_type is set to PNPushType.APNS2.
from pubnub.enums import PNPushType

envelope = yield pubnub.list_push_channels()\
    .push_type(PNPushType.GCM)\
    .device_id("deviceId")\
    .future()
The list_push_channels() operation returns a PNPushListProvisionsResult which contains the following fields:
MethodTypeDescription
Channels
List
List of channels associated for push notifications.

Requires Mobile Push Notifications add-on XRequires that you enable the Mobile Push Notifications for your key. Refer to the following page for details on enabling add-on features on your keys:

https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-keys-.
Disable push notifications on provided set of channels. If nil will be passed as channels then client will remove push notifications from all channels which associated with pushToken.
To run Removing Device From Channel you can use the following method(s) in the Python-Tornado V4 SDK:
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesn/aThe available push types. Accepted values: PNPushType.GCM, PNPushType.FCM, PNPushType.APNS, PNPushType.APNS2
    channelsListYesn/aThe channels to add the push notifications to.
    device_idStringYesn/aThe device ID (token) to associate with the push notifications.
    topicStringRequired for PNPushType.APNS2n/aThe topic name for the notification. For the Apple platform, this is the application's bundle identifier. Required only if push_type is set to PNPushType.APNS2.
    environmentStringRequired for PNPushType.APNS2PNPushEnvironment.DEVELOPMENTThe environment where the device should manage the list of channels with enabled notifications. Required only if push_type is set to PNPushType.APNS2.
from pubnub.enums import PNPushType

envelope = yield pubnub.remove_channels_from_push()\
    .push_type(PNPushType.GCM)\
    .channels("ch1", "ch2", "ch3")\
    .device_id("deviceId")\
    .future()
The remove_channels_from_push() does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.is_error().