Trigger.io

Trigger.io Forge Documentation

Important

This documentation is deprecated, and only kept here to support users of browser extension APIs. If you are using Trigger.io for iOS or Android, see https://trigger.io/docs/.

push: notifications (with Parse)

"Add a Backend to Your Mobile App in Minutes" - Parse allows you to add backend features to your mobile app without a server. Their back end features include a datastore, user accounts and push notifications.

For a small example on our blog, see Using Parse and Trigger.io for cross-platform apps without pain in the back-end.

Parse push notifications are integrated directly Forge. Other Parse features may be accessed by using forge.request.ajax with the Parse REST API.

Configuring Push Notifications

First you'll need to register an app at parse.com.

In order for your app to communicate with the Parse servers for push notifications you must specifiy both your applicationId and clientKey in your app's config.json as shown:

"partners": {
    "parse": {
        "applicationId": "YourApplicationKeyZdAtirdSn02Qy6NofiU2Hf",
        "clientKey": "YourClientKeyZdAtirdSn02QQy6NofiU2Hfy6No"
    }
}

Note

This Parse configuration must go in the partners section of your config.json, not modules as is the norm with normal Forge modules.

API: forge.partners.parse

Push notifications received through Parse can be used with the generic push notification event in Forge, see the event API for more details. The following code is an example of how to show an alert to a user when a push notification is received.

Example:

forge.event.messagePushed.addListener(function (msg) {
    alert(msg.alert);
});

You can try out sending a push notification from your app's control panel at parse.com.

Parse uses channels to send push notifications to specific groups of users. By default all users are subscribed to the empty channel; if you wish to send push notifications to specific users, you can use the following methods to manage which channels a user is subscribed to.

installationInfo

Platforms: Mobile

Every Parse installation has a unique ID associated with it; you can use this method to retrieve the installation ID for this user and do things like advanced targetting of push notifications.

parse.installationInfo(success, error)
Arguments:
  • success (function(info)) -- Called if the request is successful: info will contain at least an id entry
  • error (function(content)) -- Called with details of any error which may occur

Example:

forge.partners.parse.installationInfo(function (info) {
    forge.logging.info("installation: "+JSON.stringify(info));
});

push.subscribe

Platforms: Mobile

parse.push.subscribe(channel, success, error)
Arguments:
  • channel (string) -- Identifier of the channel to subscribe to
  • success (function()) -- Called if the request is successful
  • error (function(content)) -- Called with details of any error which may occur

Example:

forge.partners.parse.push.subscribe("beta-testers",
function () {
  forge.logging.info("subscribed to beta-tester push notifications!");
},
function (err) {
  forge.logging.error("error subscribing to beta-tester notifications: "+
    JSON.stringify(err));
});

push.unsubscribe

Platforms: Mobile

parse.push.unsubscribe(channel, success, error)
Arguments:
  • channel (string) -- Identifier of the channel to unsubscribe from
  • success (function()) -- Called if the request is successful
  • error (function(content)) -- Called with details of any error which may occur

Example:

forge.partners.parse.push.unsubscribe("beta-testers",
function () {
  forge.logging.info("no more beta-tester notifications...");
},
function (err) {
  forge.logging.error("couldn't unsubscribe from beta-tester notifications: "+
    JSON.stringify(err));
});

push.subscribedChannels

Platforms: Mobile

parse.push.subscribedChannels(success, error)
Arguments:
  • success (function(channels)) -- Called with an array of subscribed channels
  • error (function(content)) -- Called with details of any error which may occur

Example:

forge.partners.parse.push.subscribedChannels(
function (channels) {
  forge.logging.info("subscribed to: "+JSON.stringify(channels));
},
function (err) {
  forge.logging.error("couldn't retreive subscribed channels: "+
    JSON.stringify(err));
});

Permissions

On Android this module will add the VIBRATE and RECEIVE_BOOT_COMPLETED permissions to your app, users will be prompted to accept this when they install your app.