Last active
March 4, 2019 21:02
-
-
Save johhansantana/08048abe59180510c869bb87191d26fc to your computer and use it in GitHub Desktop.
push notification with working headsup display on android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const admin = require("firebase-admin"); | |
const serviceAccount = require("./serviceAccountKey.json"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount), | |
databaseURL: "your database url (optional)" | |
}); | |
module.exports = (req, res) => { | |
const payload = { | |
notification: { | |
title: "You have been invited to a tripp.", | |
body: "Tap here to check it out!", | |
}, | |
data: { | |
channelId: "test-channel" | |
}, | |
android: { | |
priority: "high", | |
notification: { | |
channelId: "test-channel", | |
sound: "default" | |
} | |
}, | |
apns: { | |
// headers: { | |
// 'apns-priority': '10', | |
// }, | |
payload: { | |
aps: { | |
sound: "default" | |
} | |
} | |
}, | |
token: | |
"your phone device id" | |
}; | |
admin.messaging().send(payload); | |
return res.send("Message sent!"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment