Open mvaljento opened 3 years ago
It's not mentioned in the FCM documentation but has you try sound=null? https://firebase.google.com/docs/cloud-messaging/http-server-ref#send-downstream
@RidClick Thanks for the suggestion. If the sound is null or empty string, the sound is disabled, but the FCM handler is not firing even when the app is in the foreground. Xcode logs still show following:
{ aps = { category = "FCM_PLUGIN_ACTIVITY"; "content-available" = 1; }; "gcm.message_id" = [MY_MESSAGE_ID]; "gcm.notification.priority" = normal; "google.c.sender.id" = [MY_SENDER_ID]; type = "users-update"; }
Excuse me, I had thought that your problem was simply due to the sound of the notifications. But in effect your problem is the same as mine, the plugin does not control the content-available parameter in iOS, so notifications are always shown even if the app is in the foreground. I am still waiting for the solution that the developer can provide.
@RidClick What I don't understand is, why is this behaviour dependent on the "sound" parameter? How does sound parameter in the notification relate to whether the plugin processes it or not? It has to be a bug.
I think all the apns parameters are not included in the plugin, that's why the sound parameter is not working properly
I'm attempting to get so-called silent notifications (data messages) working on iOS as they do on Android. These should essentially be notifications which only have "conent-available" property and key-value pairs for the data and do not display a notification "toast" or sound when the app is running either foreground or background.
These sort of notifications do arrive on the device (seen from the XCode console), but seem not to be correclty handled by the plugins onNotification -handler.
Below is the payload I'm sending. If I completely omit the "sound" property, the notification still arrives but is not handled. The problem is that if I leave the sound property there, it works correctly when the app is on the foreground, but if the app is running in the background, there's no notification "toast" but the notification sound is still heard which is not desirable for background data updates.
Is it possible to get the background "data" notifications working silently? Setting sound "disabled" doesn't work either. It will still give a "ping" when arriving on background.
{ "to": "[MY-TOKEN]", "token": "[MY-TOKEN]", "priority": "high", "time_to_live": 0, "data": { "id": 1610052394009, "type": "photos-update" }, "notification": { "content_available": true, "content_mutable": true, "sound": "default", // if this is left out, onNotification is not fired "icon": "fcm_push_icon", "tag": 1610052394009, "click_action" => "FCM_PLUGIN_ACTIVITY" } }
And this what XCode console shows when it receives the data (and in this case the onNotification handler is fired as expected):
{ aps = { category = "FCM_PLUGIN_ACTIVITY"; "content-available" = 1; sound = default; }; "gcm.message_id" = 1610360499961912; "gcm.notification.content_mutable" = true; "google.c.sender.id" = 953195669266; id = 1610052394009; type = "photos-update"; }
When I leave out the sound property, this is what is received (and onNotification handler is NOT fired):
{ aps = { category = "FCM_PLUGIN_ACTIVITY"; "content-available" = 1; }; "gcm.message_id" = 1610361213694033; "gcm.notification.content_mutable" = true; "google.c.sender.id" = 953195669266; id = 1610052394009; type = "photos-update";