Firebase API is not sending push notifications when using the API

前端 未结 2 2074
無奈伤痛
無奈伤痛 2020-12-06 13:16

I\'m migrating from Parse to Firebase and facing a problem with our ios app. The Firebase API does not send push notifications to the ios app. This is what im sending to htt

相关标签:
2条回答
  • 2020-12-06 13:32

    The object you send to https://fcm.googleapis.com/fcm/send with Firebase API should look like this :

    {
      "notification":{
        "title":"Notification title",  //Any value
        "body":"Notification body",  //Any value
        "sound":"default", //If you want notification sound
        "click_action":"<activity_name>",  //Must be present for Android
        "icon":"fcm_push_icon"  //White icon Android resource
      },
      "data":{
        "param1":"value1",  //Any data to be retrieved in the notification callback
        "param2":"value2"
      },
        "to":"/topics/topicExample", //Topic or single device
        "priority":"high", //If not set, notification won't be delivered on completely closed iOS app
        "restricted_package_name":"" //Optional. Set for application filtering
    }
    

    Please if your problem has been solved don't forget to mark it as such.

    0 讨论(0)
  • 2020-12-06 13:39

    I got contacted by Firebase support and was able to find out what is wrong

    My push payload was missing a notification object

    { 
     "to": "<registration token>",
     "priority": "high",
     "notification": {
        "title": "Your Title",
        "text": "Your Text"
      }
     "data": {
         "customId": "<my custom id>",
         "badge": 1,
         "sound": "cheering.caf",
        "alert": "New data is available"
      }
    }
    

    I hope that helps someone else

    0 讨论(0)
提交回复
热议问题