CrossGeeks / FirebasePushNotificationPlugin

Firebase Push Notification Plugin for Xamarin iOS and Android
MIT License
395 stars 178 forks source link

PushNotifications not woking correctly when app android is closed #220

Closed acolangelo86 closed 4 years ago

acolangelo86 commented 5 years ago

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

Version Number of Plugin: Device Tested On: Simulator Tested On: Version of VS: Version of Xamarin: Versions of other things you are using:

Steps to reproduce the Behavior

Expected Behavior

Actual Behavior

Code snippet

Screenshots

acolangelo86 commented 5 years ago

Hi, I have a problem. I've implemented FCM in my xamarin forms app. I need to send to the users a notification with custom properties inside. When user tap on the notification the APP must call a web service passing the custom properties. The notification is sent only once for both android and ios whit a payload similar to the following:

{
   "to":"/topics/genericTopic",
   "notification": {
    "body": "This is a notification",
    "customProperty1":"customProperty1",
        "customProperty2":"customProperty2",
        "sound": "default",
    "content_available" : true
  },
   "data":{
      "priority": "high",
      "silent":false,
      "message": "This is a notification",
      "sound":"default",
     "customProperty1":"customProperty1",
     "customProperty2":"customProperty2",
   }
}

In iOS it works perfectly, but in Android it works only when the app is in Foreground or in Background. When the app is closed it doesn't work correctly. When I tap on the notification I cannot read custom properties. Please can someone help me? Thanks

acolangelo86 commented 5 years ago

If I send a notification with the following payload it works correctly also when android app is closed.

{
   "to":"/topics/genericTopic",
   "data":{
      "message": "This is a notification",
     "customProperty1":"customProperty1",
     "customProperty2":"customProperty2",
   }
}

But the problem is that the server needs to send only a notification one time and it must be available both for android and iOS. The code above works only for Android. Please help me to find a solution.

Thanks

djrpascu commented 5 years ago

Try add "priority":"high" to your data payload.