Modules.Cloud.PushNotifications
> Modules.Cloud.PushNotifications

Provides methods for accessing Arrow push notification channels.

For information on configuring and setting up push notifications, see the Push Notifications guide.

The methods in this module are used to subscribe and unsubscribe from Arrow push notification channels, and to generate Arrow push notifications. Push notifications are received using platform-specific mechanisms:

  • On iOS, push notifications are received through the standard iOS push notification mechanism. When you register for push notifications, incoming push notifications are passed to the callback callback. See Network.registerForPushNotifications for details.
  • On Android, push notifications are received through the Modules.CloudPush module. Add a listener for the callback event to receive push notifications.

To register for push notifications, you need to obtain an application-specific device token. To obtain a device token:

  • On iOS, when you successfully register for push notifications, the device token is passed to the success callback.
  • On Android, use CloudPush.retrieveDeviceToken to request a device token. The device token is passed to the success callback.

Examples

Subscribe to Channel

This example subscribes to a push notification channel and checks the response.

Cloud.PushNotifications.subscribe({
    channel: 'friend_request',
    device_token: myPushDeviceToken
}, function (e) {
    if (e.success) {
        alert('Success');
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});

Unsubscribe to Channel

This example unsubscribes from a push notification channel and checks the response.

Cloud.PushNotifications.unsubscribe({
    channel: 'friend_request',
    device_token: myPushDeviceToken
}, function (e) {
    if (e.success) {
        alert('Success');
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});

Notify Channel

This example sends a push notification to a channel and checks the response.

Cloud.PushNotifications.notify({
    channel: 'friend_request',
    payload: 'Welcome to push notifications'
}, function (e) {
    if (e.success) {
        alert('Success');
    } else {
        alert('Error:\n' +
            ((e.error && e.message) || JSON.stringify(e)));
    }
});

Update Subscription

This example updates the user's notification subscription with the device's current location, upon successfully obtaining the device's current position.

var latitude, longitude, 
var pushDeviceToken; // Device token obtained earlier...

Titanium.Geolocation.getCurrentPosition(function(e) {
    if (e.error) {
        Ti.API.error('Error: ' + e.error);
    } else {
        latitude = e.coords.latitude;
        longitude = e.coords.longitude;
        Cloud.PushNotifications.updateSubscription({
            device_token: pushDeviceToken,
            loc: [longitude, latitude]
        }, function (e) {
            if (e.success) {
                alert('Subscription Updated.');
            }
            else {
                alert(e);
            }
        });                        
    }
});
  • 0.8
  • 0.8
  • 0.8
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Indicates if the proxy will bubble an event to its parent. ...

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0.0
  • 3.0.0
  • 3.0.0

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Defined By

Methods

Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • Boolean
Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Modules.Cloud.PushNotifications
( parameters, callback )
Send a push notification to a channel. ...

Send a push notification to a channel.

Requires user login.

See push_notifications/notify.json for the request parameters supported by this method.

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Send a push notification to a channel to the specified devices. ...

Send a push notification to a channel to the specified devices.

See push_notifications/notify_tokens.json for the request parameters supported by this method.

  • 3.1.2
  • 3.1.2
  • 3.1.2

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Custom query of push notification subscriptions with paginating. ...

Custom query of push notification subscriptions with paginating.

See push_notifications/query.json for the request parameters supported by this method.

Data is returned in the subscriptions property of the parameter passed to the callback.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Returns a list of push notification channels the user is subscribed to. ...

Returns a list of push notification channels the user is subscribed to.

Requires user login.

See push_notifications/channels/query.json for the request parameters supported by this method.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Resets the badge value to zero but does not update it on the device. ...

Resets the badge value to zero but does not update it on the device.

To update the badge in the device's UI, send a push notification to the device with the badge field defined.

The REST API call supports calling this method as either a PUT request or a GET request. This method only supports the PUT request, which means a device token must be passed to this method.

See push_notifications/reset_badge.json for the request parameter supported by this method.

  • 3.2.1
  • 3.2.1
  • 3.2.1

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Sets the badge value but does not update it on the device. ...

Sets the badge value but does not update it on the device.

To update the badge in the device's UI, send a push notification to the device with the badge field defined.

See push_notifications/set_badge.json for the request parameter supported by this method.

  • 3.2.1
  • 3.2.1
  • 3.2.1

Parameters

Returns

  • void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Returns the number of devices subscribed to the specified channel. ...

Returns the number of devices subscribed to the specified channel.

Requires user login.

See push_notifications/channels/show.json for the request parameters supported by this method.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Subscribe a mobile device to a push notification channel. ...

Subscribe a mobile device to a push notification channel.

Requires user login.

See push_notifications/subscribe.json for the request parameters supported by this method.

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Subscribe a mobile device to a push notification channel using a device token. ...

Subscribe a mobile device to a push notification channel using a device token.

See push_notifications/subsribe_tokens.json for the request parameters supported by this method.

  • 3.1.2
  • 3.1.2
  • 3.1.2

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Unsubscribe a mobile device from a push notification channel. ...

Unsubscribe a mobile device from a push notification channel.

Requires user login.

See push_notifications/unsubscribe.json for the request parameters supported by this method.

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Unsubscribe a mobile device from a push notification channel using a device token. ...

Unsubscribe a mobile device from a push notification channel using a device token.

See push_notifications/unsubscribe_tokens.json for the request parameters supported by this method.

  • 3.1.2
  • 3.1.2
  • 3.1.2

Parameters

Returns

  • void
Modules.Cloud.PushNotifications
( parameters, callback )
Updates a user's notification subscription with the device's location. ...

Updates a user's notification subscription with the device's location.

This allows an Appcelerator Dashboard administrator to send push notifications to devices located within a specified geographic region. For details, see Sending and scheduling push notifications.

See push_notifications/unsubscribe.json for the request parameters supported by this method.

Parameters

Returns

  • void