5

I'm using this plugin with cordova: cordova-plugin-fcm to get notifications working.

It works good on Android.

Problem is with iOS, when the app is in foreground the notifications arrives. But when the app is closed or in background, the notification doesn't show in notification bar, but when I open the application I can see the notification arriving and the popup I generate, gets opened.

But I really need to notification to show in lock screen and in the notification bar.

This is what I'm sending to Firebase API:

/ POST to https://fcm.googleapis.com/fcm/send

And in the body I'm sending this:

{
  "to" : <USER_TOKEN>,
  "alert":"Test",
  "notification": {
    "alert":"Test test",
    "title": "Notification test",
    "text": "Testing notification text"
  },
  "priority": 10,
  "content_available": true
}

I've also tried with "priority": "high" and get the same results.

The notification arrives, but it only shows when I open the app. I don't even get it in the notification bar or lock screen.

Also I tried adding the "aps" property in the body, with all the information inside.. doesn't work.

I hope someone can throw some light into this..

PS: iOS v10.1.1

PS2: Works good on all android devices.

I've already read some answers from the community but doesn't seem to work:

Firebase API is not sending push notifications when using the API

iOS not receiving Firebase Push Notification sent through the API

Thanks for your time.

Community
  • 1
  • 1
Ariel
  • 1,507
  • 2
  • 20
  • 28
  • Hi @Ariel. I'm trying to make this plugin works using Intel XDK and posted this question: http://stackoverflow.com/questions/42199487/mobile-app-using-intel-xdk-and-cordova-plugin-for-firebase-notifications. Can you help me to solve this problem? I just want to know what am I doing wrong. – Nowdeen Feb 13 '17 at 08:26
  • @Ariel I am facing same issue that notification in iOS is not displaying in notification bar. Please help me. I am stuck in this task. – Ekta Padaliya May 10 '17 at 12:14
  • @EktaPadaliya I was having problems in XCode configuration, check Capabilities, and enable push notifications, plus configuring the correct certificates. My problem was there, in Capabitilities configuration section, I did not have the Push Notifications enabled. Once I enabled them, they started to show up. – Ariel May 11 '17 at 15:12

2 Answers2

3

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

DIGAMBAR TOPE
  • 215
  • 1
  • 3
  • 7
  • i am using cordova-plugin-firebase 0.1.18 "Google Firebase Plugin its working for ios and android – DIGAMBAR TOPE Dec 28 '16 at 07:29
  • Thanks for your answer, sorry for the delay, some other projects took priority. I uploaded the .p12 certificates (dev & pro), still no signs of improvements. If the app is in foreground, i get the notification, but when iPhone is blocked, i don't get anything in the screen or notification bar. – Ariel Jan 16 '17 at 20:11
  • 2
    Ok, solved, how? Uploading .p12 and .. don't laugh: XCode -> Capabiltiies -> Push notifications (ENABLE). – Ariel Jan 16 '17 at 20:23
0

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

  • Also make sure your Development APNs certificate have been uploaded, but that should work well, assuming the fact it works inside the app already. – basco05 Mar 14 '17 at 10:22
  • Thank you @basco05, already solved this problem, I forgot to enable push notifications on my settings in "Capabilities", that solved the issue I was having. – Ariel Mar 15 '17 at 12:54