chat-engine-push-notifications-payload
v0.0.1
Published
ChatEngine APN an GCM / FCM notification payload generation plugin.
Downloads
3
Maintainers
Readme
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
- 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', () => { ... });
- 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));
- 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();
- Listen for the
$notifications.seen
events (on local userdirect
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 [email protected]