PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

titanium

  • Getting Started
  • API Reference

    • Configuration
    • Publish & Subscribe
    • Presence
    • Access Manager
    • Channel Groups
    • Message Persistence
    • Mobile Push
    • Miscellaneous
  • Status Events
  • Troubleshooting
  • Change Log
  • Feature Support
  • Platform Support

Push Notifications API for PubNub Titanium SDK

PubNub's Mobile Push Gateway feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android 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.

Adding Device to Channel

Requires Mobile Push Notifications add-on Requires 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-

Description

Enable push notifications on provided set of channels.

Method(s)

To run Adding Device to Channel you can use the following method(s) in the Titanium V4 SDK:

  1. pubnub.push.addChannels({Array channels, String device, String pushGateway, String environment, String topic},Function callback)
    
    ParameterTypeRequiredDefaultsDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelsArrayYesSpecifies channel to associate with push notifications.
    deviceStringYesThe device ID to associate with push notifications.
    pushGatewayStringYesapns, apns2 or gcm.
    environmentStringOptionaldevelopmentEnvironment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2).
    topicStringOptionalNotifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2.
    callbackFunctionOptionalExecutes on a successful/unsuccessful addChannels.

Basic Usage

Adding Device to Channel:

pubnub.push.addChannels(
    {
        channels: ['my_chat'],
        device: 'A655FBA9931AB',
        pushGateway: 'apns' // apns, gcm
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!")
        }
    }
);

Response

{
    error: false,
    operation: 'PNPushNotificationEnabledChannelsOperation',
    statusCode: 200
}

Listing Channels For Device

Requires Mobile Push Notifications add-on Requires 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-

Description

Request for all channels on which push notification has been enabled using specified pushToken.

Method(s)

To run Listing Channels For Device you can use the following method(s) in the Titanium V4 SDK:

  1. pubnub.push.listChannels({String device, String pushGateway, String environment, String topic},Function callback)
    
    ParameterTypeRequiredDefaultsDescription
    Operation ArgumentsHashYesA hash of arguments.
    deviceStringYesThe device ID to associate with push notifications.
    pushGatewayStringYesapns, apns2 or gcm.
    environmentStringOptionaldevelopmentEnvironment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2).
    topicStringOptionalNotifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2.
    callbackFunctionOptionalExecutes on a successful/unsuccessful listChannels.

Basic Usage

Listing Channels For Device:

pubnub.push.listChannels(
    {
        device: 'A655FBA9931AB',
        pushGateway: 'apns' // apns, gcm
    },
    function (status, response) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
            return;
        }

        console.log("listing push channel for device");
        response.channels.forEach( function (channel) {
            console.log(channel);
        });
    }
);

Response

// Example of status
{
    error: false,
    operation: 'PNPushNotificationEnabledChannelsOperation',
    statusCode: 200
}

// Example of response
{
    channels: [ 'a', 'b' ]
}

Removing Device From Channel

Requires Mobile Push Notifications add-on Requires 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-

Description

Disable push notifications on provided set of channels.

Method(s)

To run Removing Device From Channel you can use the following method(s) in the Titanium V4 SDK:

  1. pubnub.push.removeChannels({Array channels, String device, String pushGateway, String environment, String topic},Function callback)
    
    ParameterTypeRequiredDefaultsDescription
    Operation ArgumentsHashYesA hash of arguments.
    channelsArrayYesSpecifies channel to associate with push notifications.
    deviceStringYesThe device ID to associate with push notifications.
    pushGatewayStringYesapns, apns2 or gcm.
    environmentStringOptionaldevelopmentEnvironment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2).
    topicStringOptionalNotifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2.
    callbackFunctionOptionalExecutes on a successful/unsuccessful removeChannels.

Basic Usage

Removing Device From Channel:

pubnub.push.removeChannels(
    {
        channels: ['my_chat'],
        device: 'A655FBA9931AB',
        pushGateway: 'apns' // apns, gcm
    },
    function(status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);

Response

{
    error: false,
    operation: 'PNPushNotificationEnabledChannelsOperation',
    statusCode: 200
}

Remove all push notifications

Requires Mobile Push Notifications add-on Requires 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-

Description

Disable push notifications from all channels registered with the specified pushToken.

Method(s)

To run Remove all push notifications you can use the following method(s) in the Titanium V4 SDK:

  1. pubnub.push.deleteDevice({String device, String pushGateway, String environment, String topic},Function callback)
    
    ParameterTypeRequiredDefaultsDescription
    Operation ArgumentsHashYesA hash of arguments.
    deviceStringYesThe device ID to associate with push notifications.
    pushGatewayStringYesapns, apns2 or gcm.
    environmentStringOptionaldevelopmentEnvironment within which device should manage list of channels with enabled notifications (works only if pushGateway set to apns2).
    topicStringOptionalNotifications topic name (usually it is bundle identifier of applicationfor Apple platform). Required only if pushGateway set to apns2.
    callbackFunctionOptionalExecutes on a successful/unsuccessful deleteDevice.

Basic Usage

Remove all push notifications:

pubnub.push.deleteDevice(
    {
        device: 'A655FBA9931AB',
        pushGateway: 'apns' // apns, gcm
    },
    function (status) {
        if (status.error) {
            console.log("operation failed w/ error:", status);
        } else {
            console.log("operation done!");
        }
    }
);

Response

{
    error: false,
    operation: 'PNPushNotificationEnabledChannelsOperation',
    statusCode: 200
}
← Message PersistenceMiscellaneous →
  • Adding Device to Channel
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Listing Channels For Device
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Removing Device From Channel
    • Description
    • Method(s)
    • Basic Usage
    • Response
  • Remove all push notifications
    • Description
    • Method(s)
    • Basic Usage
    • Response
© PubNub Inc. - Privacy Policy