Skip to content

Instantly share code, notes, and snippets.

@johhansantana
Last active March 4, 2019 21:02
Show Gist options
  • Save johhansantana/08048abe59180510c869bb87191d26fc to your computer and use it in GitHub Desktop.
Save johhansantana/08048abe59180510c869bb87191d26fc to your computer and use it in GitHub Desktop.
push notification with working headsup display on android
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