fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 990 forks source link

Android background works if not set FCM_PLUGIN_ACTIVITY #580

Open scrabionau77 opened 5 years ago

scrabionau77 commented 5 years ago

I point out an anomaly, which could be useful to others! In the plugin and firebase documentation it is said to insert "click_action" in the payload. But if I enter "click_action" => "FCM_PLUGIN_ACTIVITY", the app won't start when I click on the notification!

I spent hours figuring out why the app didn't start from the notification! Then I removed "click_action" => "FCM_PLUGIN_ACTIVITY" and everything works perfectly!

For completeness, I report the json I send to FCM via PHP script

` $notification = array( "title" => $titolo, "body" => $messaggio, "icon" => "fcm_push_icon", "sound" => "default", "tag" => $tag, "color" => "#0271ac", //"click_action" => "FCM_PLUGIN_ACTIVITY", // COMMENTED!!!! "collapse_key" => $tag );

$data = array( 'message' => $messaggio );

$fields = array ( 'to' => $token, 'data' => $data, 'notification' => $notification, 'collapse_key' => $tag, 'priority' => 'high', 'content_available' => true ); `

I'm using Cordova 8.1.2, platform Android 7.1.4

mfdeveloper commented 4 years ago

Hello @scrabionau77 !

Can you share your js code when subscribe to onNotification() ? Are you trying execute something verifiying if(data.wasPressed) ?