android - Firebase Cloud Messaging not sending data payload -


from firebase cloud messaging documentation @ defining message payload:

you can specify 1 or both message types creating object data , / or notification keys.

the documentation gives example of combined message:

var payload = {   notification: {     title: "$goog 1.43% on day",     body: "$goog gained 11.80 points close @ 835.67, 1.43% on day."   },   data: {     stock: "goog",     open: 829.62,     close: "635.67"   } }; 

also documentation @ handle notification messages in backgrounded app:

this includes messages contain both notification , data payload (and messages sent notifications console). in these cases, notification delivered device's system tray, , data payload delivered in extras of intent of launcher activity.

i'm sending notification payload:

const payload = {     notification: {         title: '...',         body: '...',     },     data: {         test: "test"     }, }; admin.messaging().sendtodevice(tokens, payload).then(...) 

but extras null:

intent intent = getintent(); if (intent != null) {     bundle extras = intent.getextras();     if (extras != null) {         //     } } 

what doing wrong?

app behavior when receiving messages include both notification , data payloads depends on whether app in background or foreground—essentially, whether or not active @ time of receipt.

  • when in background, apps receive notification payload in notification tray, , handle data payload when user taps on notification.

  • when in foreground, app receives message object both payloads available.

so, if app in foreground intent wouldn't have notification extras. if that's not case doing wrong in configuration.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -