我有一个使用fcm实现的应用程序。在所有情况下,我都可以接收到推送通知,这很好。但是如果应用程序被用户终止/杀死,则不会调用didReceiveRemoteNotification
方法。如果应用程序在后台或前台中,它将被调用。应用程序被终止时通知会出现,但didReceiveRemoteNotification:fetchCompletionHandler
没有被调用。
我的问题是,当应用程序被终止并收到Firebase通知时,触发哪个方法。我使用了Swift 4.2和Xcode 10.0。我在功能中启用了背景模式-来自远程通知的通知。
使用Firebase,我发送了以下JSON:
{
"to": "/topics/group1",
"priority" : "high",
"content-available": true,
"notification" : {
"body" : "Yes you recevied !",
"sound": "default",
"title" : "Notification"
},
"data": {
"type" : "IOS"
}
}
didReceiveRemoteNotification:fetchCompletionHandler
永远不会被调用。相反,当用户点击通知时,数据将在didFinishLaunchingWithOptions
中接收。 - NightFury