我正在尝试调试为什么我不能在我的iPhone上从firebase获取消息,我连接到了FCM服务器,并且我还订阅了一个主题,然而,当我尝试打印从FCM接收的数据时,我得到的值是空值。
这是我从google的教程中得到的代码,它被执行,所以这是否意味着应用程序被正确地通知在FCM上有一个新的主题可用?
另外,我如何调试,以查看我在设置FCM时是否做错了什么?
谢谢
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
// Print message ID.
FIRMessaging.messaging().subscribe(toTopic: "/topics/newNotificationtest")
print("Message ID: \(userInfo["gcm.message_id"])")
debugPrint(userInfo)
// Print full message.
print("%@", userInfo)
}发布于 2017-07-07 21:44:20
请尝试使用此代码并进行调试
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
FIRMessaging.messaging().appDidReceiveMessage(userInfo)
let aps = userInfo["aps"] as? NSDictionary
print(aps)
print(userInfo)
print("Message ID: \(userInfo["gcm.message_id"]!)")
print("%@", userInfo)
}https://stackoverflow.com/questions/44972073
复制相似问题