Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const sendNotification = functions.https
- .onRequest(async (req, res) => {
- try {
- const { token } = req.query;
- let tokens = 'fyTfgNZAUBA:APA91bGnx9Vp9MwRA4ohVKcNOM8d5s4a4TXdtI0KTSzcWEgZX1WoLGpofcVQFTCdSbnbqObkukzJEXF3cbmvENYD5pr2MrukjqUNy_bclDuM3rJsV5iSU1vWywL2ZVijJ3s0E9GNfRRe'
- var payload = {
- /*
- data = {
- name:'test'
- content:'bla bla'
- }
- */
- notification: {
- title: 'Urgent action needed!',
- body: 'Urgent action is needed to prevent your account from being disabled!',
- sound: 'default',
- color: '#84B2D9',
- icon: 'ic_notification',
- click_action: 'OPEN_MAIN_ACTIVITY'
- }
- };
- // Set the message as high priority and have it expire after 24 hours.
- var options = {
- priority: 'high',
- timeToLive: 60 * 60 * 24
- };
- console.log('token',token)
- let d = await admin.messaging().sendToDevice(tokens, payload,options);
- return res.status(200).send({ success: d})
- } catch (e) {
- console.info(e)
- return res.status(400).send({ error: 0 })
- }
Advertisement
Add Comment
Please, Sign In to add comment