SelectPython-Tornado Mobile Push API Reference for Realtime Apps

These docs are for version 3.9.0 of the Python-Tornado SDK. To check out the docs for the latest version Click Here.
 

PubNub 4.0 for Python-Tornado is our latest and greatest! Please click here for our PubNub 4.0 for Python docs and SDK.

PubNub 3.x for Python-Tornado will encounter End Of Life (EOL) July 1st, 2017. All users currently on 3.x should begin migrating to 4.x. The 3.x SDK will continue to work. We will no longer support it and if you run into an issue, we will request that you upgrade to the latest version before solving the issue.

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), Apple iOS APNs (Apple Push Notification service), and Microsoft Windows Phone MPNS (Microsoft 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:

http://www.pubnub.com/knowledge-base/discussion/644/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 SDK
  1. ParameterTypeRequiredDescription
    device_idStringYesThe device id to associate with push notifications.
    callbackFunctionOptionalA callback method can be passed to the method. If set, the api works in async mode. Required argument when working with twisted or tornado.
    channel_to_addStringYesSpecifies channel to associate with push notifications. Comma separated values are accepted.
    gw_typeStringYesapns, mpns or gcm.
    errorFunctionOptionalAn error method can be passed to the method. If set, the api works in async mode. Required argument when working with twisted or tornado.
def _callback(message):
	print(message)

def _error(error):
	print(error)

pubnub.mobile_gw_provision(device_id = 'niceDevice', channel_to_add='ch1,ch2', gw_type ='apns', callback=_callback, error=_error)
[1, "Modified Channels"]

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:

http://www.pubnub.com/knowledge-base/discussion/644/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 SDK
  1. ParameterTypeRequiredDescription
    device_id
    String
    Yes
    The device id to list the push notifications channel.
    callback
    Function
    Optional
    Callback object which contains callbacks for success, error etc. Required argument when working with twisted or tornado.
    gw_type
    String
    Yes
    apns, mpns or gcm.
    error
    Function
    Optional
    An error method can be passed to the method. If set, the api works in async mode. Required argument when working with twisted or tornado.
def _callback(message):
	print(message)

def _error(error):
	print(error)

pubnub.mobile_gw_provision(device_id = 'niceDevice', gw_type ='apns', callback=_callback, error=_error)
The output below demonstrates the response to a successful call:
will contain a list of channels registered 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:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications on provided set of channels.
To run Removing Device From Channel you can use the following method(s) in the Python SDK
  1. ParameterTypeRequiredDescription
    device_id
    String
    Yes
    The device id to remove the push notifications.
    callback
    Function
    Optional
    Callback object which contains callbacks for success, error etc. Required argument when working with twisted or tornado.
    channel_to_remove
    String
    Yes
    Specifies channel to disassociate the push notifications. Comma separated values are accepted.
    gw_type
    String
    Yes
    apns, mpns or gcm.
    error
    Function
    Optional
    An error method can be passed to the method. If set, the api works in async mode. Required argument when working with twisted or tornado.
def _callback(message):
	print(message)

def _error(error):
	print(error)

pubnub.mobile_gw_provision(device_id = 'niceDevice', channel_to_remove ='ch1', gw_type ='apns', callback=_callback, error=_error)
The output below demonstrates the response to a successful call:
[1, "Modified Channels"]

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:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
Disable push notifications from all channels registered with the specified pushToken.
To run Remove all push notifications you can use the following method(s) in the Python SDK
  1. ParameterTypeRequiredDescription
    device_id
    String
    Yes
    The device id to disassociate with from push notifications.
    remove_device
    Boolean
    Yes
    Disassociate device from push notifications.
    callback
    Function
    Optional
    Callback object which contains callbacks for success, error etc. Required argument when working with twisted or tornado.
    gw_type
    String
    Yes
    apns, mpns or gcm.
    error
    Function
    Optional
    An error method can be passed to the method. If set, the api works in async mode. Required argument when working with twisted or tornado.
def _callback(message):
	print(message)

def _error(error):
	print(error)

pubnub.mobile_gw_provision(device_id = 'niceDevice', remove_device=true, gw_type ='apns', callback=_callback, error=_error)
The server responds with a status code of 200.