Push Service

Push Service provides integration with native mobile push notifications. It is especially valuable when Bit6 is used in applications based on Cordova, PhoneGap or React Native.

Prerequisites

Follow the guides to sign up for push notification services with the providers.

Initialization

The only argument needed to initialize a connection to the Push Service is an AccessToken instance.

// Init Push Service
var pushSvc = new bit6.Push(accessToken);

Device Registration

When your app launches, you will use the platform specific APIs to register the device with the push service and then send the push token to the Bit6 platform.

Obtain Push Token

TODO: Cordova example

TODO: React Native example

Register

Once you obtain the push token, you need to to register it with Bit6 push service.

// Register Android FCM push token
pushSvc.register({service: 'fcm', token: 'abcdef'});

Unregister

It is important to unregister from the push notifications when the user logs out from your application. Otherwise the device will contnue to receive and display push notifications for this user.

// Unregister the device
pushSvc.unregister();

Send Notification

The Push Service allows a user to send a push notification to another user. The destination address can be:

The notification needs to include service-specific payloads.

// FCM payload
var fcm = {
};
// APNS payload
var apns = {
};
pushSvc.send( {to: 'alice', fcm: fcm, apns: apns} );

Receive Notification

The code to receive notifications depends on the development platform and library used.