fknChaos
fknChaos

Reputation: 113

iOS not receiving notifications from Firebase Cloud Messaging

I want the push notification to only contain the title. When I send a message from the Firebase console, it works, but when I try to do the same via the API, it doesn't work for iOS (works fine on Android).

Edit: What I'm trying to accomplish is to only show the title in the notification that shows up in the notification drawer when the app is not open. If body is added, it is shown under the title in the notification.

This is the push notification I'm sending:

{
    "to": "/topics/breaking",
    "priority":"high",
    "notification": {
        "title":"Dette er en test"
    }
}

And I get nothing back

If I add body to the notification:

{
    "to": "/topics/breaking",
    "priority":"high",
    "notification": {
        "title":"Dette er en test",
        "body":"hello"
    }
}

I get this in return

{
    aps = {
        alert = {
            body = Hello;
            title = "Dette er en test";
        };
    };
    "gcm.message_id" = "xxxxxxx";
}

Here is the code to print out what I receive:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
    self.parseNotification(application, userInfo: userInfo as NSDictionary!)
}

func parseNotification(_ application: UIApplication, userInfo: NSDictionary!) {

    print(userInfo)
}

How can I get the notification on iOS without adding body to the request?

Upvotes: 1

Views: 2163

Answers (2)

Vlad
Vlad

Reputation: 3597

Please try to add certificates for push notifications: for development and production.

Upvotes: 0

fknChaos
fknChaos

Reputation: 113

I figured it out!

If I drop the title and ONLY post body it works.

{
    "to": "/topics/breaking",
    "priority":"high",
    "notification": {
        "body": "Dette er en test"
    }
}

Upvotes: 3

Related Questions