【发布时间】:2016-10-27 18:17:22
【问题描述】:
我有一个应用程序。它使用 FCM 推送通知。消息的 json 看起来像:
{ "to": "xxx", "notification" : {
"body" : "Hi",
"badge" : 1,
"sound" : "default"
},
"data" : {
"id" : "xxx",
"first_name" : "xxx",
"last_name" : "xxx",
"full_name" : "xxx",
"primary_image" : "xxx",
"matchid" : "xxx",
"type": "match"/"message"
},
"content_available": true,
"priority": "high"
}
我在数据中有一个“类型”来检测触摸我的通知时将启动哪个屏幕。如果 type == "match" -> 转到 MatchVC,然后键入 == "message" -> 转到 MessageVC。我有一个问题,如果我的应用程序在前台,我可以从didReceiveRemoteNotification:userinfo 获取数据,然后我可以检测到推送屏幕,但是如果我的应用程序是后台或关闭,我只会收到没有来自didReceiveRemoteNotification:userinfo 的数据的通知。当我点击通知时,它只会打开我的应用程序。任何解决方案都值得赞赏。
【问题讨论】:
标签: ios swift firebase push-notification firebase-cloud-messaging