PythonTwistedTwistedTornadoAsyncioNativePython-Twisted V4 Mobile Push API Reference for Realtime Apps

 

NOTICE: Based on current web trends and our own usage data, PubNub's Python Twisted SDK is deprecated as of May 1, 2019. Deprecation means we will no longer be updating the Python Twisted SDK but will continue to support users currently using it. Please feel free to use our other Python SDK offerings as they will continue to be supported and maintained. If you would like to use the Python Twisted SDK specifically, we would love to work with you on keeping this project alive!

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 3rd-party push notification providers.

Learn more about our Mobile Push Gateway here.


Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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-Twisted V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    channelsListYesAdd push notifications on the specified channels.
    device_idStringYesDevice id.
from pubnub.enums import PNPushType

d = pubnub.add_channels_to_push()\
    .push_type(PNPushType.GCM)\
    .channels(["ch1", "ch2", "ch3"])\
    .device_id("deviceId")\
    .deferred()
d.addCallback(my_callback)
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 the Mobile Push Notifications add-on is enabled for your key. See this page 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-Twisted V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    device_idStringYesDevice id.
from pubnub.enums import PNPushType

d = pubnub.list_push_channels()\
    .push_type(PNPushType.GCM)\
    .device_id("deviceId")\
    .deferred()
d.addCallback(my_callback)
The list_push_channels() operation returns a PNPushListProvisionsResult which contains the following fields:
MethodTypeDescription
Channels
List
List of channels subscribed for push notifications.

Requires Mobile Push Notifications add-on XRequires that the Mobile Push Notifications add-on is enabled for your key. See this page 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. 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-Twisted V4 SDK
  1. ParameterTypeRequiredDefaultsDescription
    push_typePNPushTypeYesNot setAccepted values: PNPushType.GCM, PNPushType.APNS, PNPushType.MPNS.
    channelsListYesRemove push notifications from the specified channels.
    device_idStringYesDevice id.
from pubnub.enums import PNPushType

d = pubnub.remove_channels_from_push()\
    .push_type(PNPushType.GCM)\
    .channels("ch1", "ch2", "ch3")\
    .device_id("deviceId")\
    .deferred()
d.addCallback(my_callback)
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().