didReceiveRemoteNotification function doesn't called with FCM notification server

后端 未结 6 954
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 10:00

I\'m using FCM server for remote notifications, it worked perfectly with sending and receiving notifications.

My problem is when the device is in the background, thi

6条回答
  •  旧时难觅i
    2020-12-11 10:15

    Just adding on accepted answer: in my case the problem was the same, but as I'm sending the Notification through an http "POST" NSMUtableRequest the way to apply the accepted answer was to actually add it in the notification parameters together with sound, badge, tiles etc etc..

    let postParams: [String : Any] = [
                    "to": receiverToken,
                    "notification": [
                        "badge" : 1,
                        "body": body,
                        "title": title,
                        "subtitle": subtitle,
                        "sound" : true, // or specify audio name to play
                        "content_available": true, // this will call didReceiveRemoteNotification in receiving app, else won't work
                        "priority": "high"
                    ],
                    "data" : [
                        "data": "ciao",
                ]
                    ]
    

    Hope this will also help others, as I spent a long time trying to figure out how to apply this solution. Many thanks.

提交回复
热议问题