cordova, Firebase, FCM Plugin - Not showing notifications in notification bar on iOS

前提是你 提交于 2019-12-03 08:02:50

have you Upload your Development APNs certificate on console.firebase.google.com,

Upload your APNs certificate to Firebase. If you don't already have an APNs certificate, see Provisioning APNs SSL Certificates.

Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab. Select the Upload Certificate button for your development certificate, your production certificate, or both. At least one is required. For each certificate, select the .p12 file, and provide the password, if any. Make sure the bundle ID for this certificate matches the bundle ID of your app. Select Save.

you can refer link https://firebase.google.com/docs/cloud-messaging/ios/client

I had the same problem, First of all, you need to use "body" instead of "text"; For priority you should always use "high" or "normal", for pushnotifications the default value should be high. If you forget to use the "title" and "body" key in the notification object of your Json string, iOS wont add the notification to the notificatios list apparently.

If you want some custom values, then add a data object with custom values. like this:

    "data":{
     "data1":"value1",
     "data2":"value2"
  }

So try something like this:

{
  "to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
   "notification": {
    "title": "Notification test",
    "body": "Testing notification text"
  },
      "priority": high,
      "sound":"default", //not using this one wont make your iOS device use sound
      "click_action":"FCM_PLUGIN_ACTIVITY",
      "icon":"fcm_push_icon"
}

Combined with data object:

     {
          "to" : <USER_TOKEN>, //or /topics/<topicname> or /topics/all"
          "notification": {
            "title": "Notification test",
            "body": "Testing notification text"
          },
          "data":{
             "data1":"value1",
             "data2":"value2"
          },
          "priority": high,
          "sound":"default", //not using this one wont make your iOS device use sound
          "click_action":"FCM_PLUGIN_ACTIVITY",
          "icon":"fcm_push_icon"
      }

I hope this helps, it did for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!