0.0.1 • Published 5 years ago

chat-engine-push-notifications-payload v0.0.1

Weekly downloads
7
License
SEE LICENSE IN LI...
Repository
github
Last release
5 years ago

Push Notifications Payload Plugin

Adds the ability to add to modify event payload with data, which is used to trigger remote push notifications.

Quick Start

  1. Have ChatEngine instantiated and connected, and have a chat you want to enable for push notification payload addition
const ChatEngine = ChatEngineCore.create({
    publishKey: 'pub-key-here',
    subscribeKey: 'sub-key-here',
});

ChatEngine.connect('Username');
ChatEngine.on('$.ready', () => { ... });
  1. Attach this plugin to the chat you want, in this case global
let configuration = {
    events: ['message', 'ping'],
    formatter: (eventPayload) => ({
        apns: { aps: { alert: { title: 'Test title', body: 'Test body' } } },
        gcm: { data: { contentTitle: 'Test title', contentText: 'Test body', ticker: 'Testing' } } 
    })
};

ChatEngine.global.plugin(ChatEngineCore.plugin['chat-engine-push-notifications-payload'](configuration));
  1. If it is required to mark notifications for event as seen, following methods can be used
// Mark specific notification / event as seen.
ChatEngine.global.on('message', (payload) => {
    ChatEngine.global.notificationsPayload.markNotificationAsSeen(payload);
});
// Mark all notifications / event as seen.
ChatEngine.global.notificationsPayload.markAllNotificationAsSeen();
  1. Listen for the $notifications.seen events (on local user direct chat) to know, when this user seen notification for event on another device.
ChatEngine.me.direct.on('$notifications.seen', () => {
    console.log(payload.data.eid, ' has been seen from another ChatEngine instance');
});

Support

  • If you need help, have a general question a feature request or to file a bug, contact support@pubnub.com