Sergej
Sergej

Reputation: 2176

Receiving Push Notification on the Iphone

Hello I'm stuck and I need help. I have an iOS application build with Angular2 + Cordova + cordova-firebase-plugin + xcode.

I have setup the app on developers.apple.com and firebase.console website. Now when I try to send a Notification message, I don't receive it on Iphone at all.

If the application is runing in the foreground, I see in the debug console that the notification was received, but it is not displayed on the Iphone.

Message from console:

Received data message: {
    "collapse_key" = "com.example.app"
    from = 793840040300;
    notification = {
        body = "example test notification message";
        e = 1;
    }
}

What I don't see here: notification title. (The notifications are working in Android, but not in iOS). There were no any prompts about enabling the notifications (permissions prompt).

I trieed to setup APNS-FCM connectivity via .p12 Certificates and via .p8 Certificates (via the key). Boths atemmpts did not give me positive result...

One more moment: IF the application is running in the background - I don't see the message in the console until I will open the app. When I open the app, the message appears in the console, if it was sent while the app was in foreground..

I viewed many different guides, but I didn't get any result.

I read that emulators does not support the push notifications, so I connected a real device via USB. And it behaves the same - no push notification received - only the message in the console.

Please, help me.

Upvotes: 1

Views: 475

Answers (1)

andreszs
andreszs

Reputation: 2956

Make sure you are sending both the title and body in the payload. I had the issue (in Android) that when not sending the message item, the notification would not show up in the notifications bar. The same applies for iOS, but in this case, the variables are title and body.

If the right variables are not found in the payload, both Android, iOS and Windows Phone will consider it a background notification that is silently delivered to the app (once it's opened). Notifications will not wake an unloaded app, the app is launched by the notification item once it's selected from the notifications bar in this case.

Try sending the default payload from the documentation to test it:

{
  "aps": {
    "alert": { // alternatively just a string: "Your Message",
      "title": "A short string describing the purpose of the notification",
      "body": "The text of the alert message",
      // localization of message is possible
      "launch-image": "The filename of an image file in the app bundle, with or without the filename extension. The image is used as the launch image when users tap the action button or move the action slider"
    },
    "badge": 5, // Number to show at App icon
    "content-available": "0", // configure background updates, see below
    "category": "identifier", // Provide this key with a string value that represents the notification’s type
    "thread-id": "id", // Provide this key with a string value that represents the app-specific identifier for grouping notifications
    "sound": "default"  // play default sound, or custom sound, see [iOS Sound](#sound-1) section
  },
  "custom_key1": "value1",
  "custom_key2": "value2"
}

If this doesn't work, please include the entire content of the payload you are sending to APNS, from the server side.

Edit: make sure you are sending your payload fields in UTF-8 encoding to all push services.

Upvotes: 1

Related Questions