1.0.1 • Published 7 years ago
fcm-web-push v1.0.1
fcm-web-push
Firebase Cloud Messaging (Web Push)
Getting started
npm i -S fcm-web-push
const FCMWP = require('fcm-web-push')
const FCM = new FCMWP()
FCM.setAuthKey('xxx')
Verify a user token
let token = 'xxx'
FCM.verifyToken(token)
.then((verified) => {
if (verified) {
...
}
else{
...
}
})
.catch((err) => {
console.log(err)
})
Send notification
let tokens = ['xxx', 'xxx']
let notification = {
"title": "Title",
"body": "Description",
"click_action": "action url",
"icon": "icon url"
}
FCM.sendNotification(tokens, notification)
.then((success) => {
if (success) {
...
}
else{
...
}
})
.catch((err) => console.log(err))