Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Swift 3调试Firebase_Swift_Xcode_Swift3_Push Notification_Google Cloud Messaging - Fatal编程技术网

使用Swift 3调试Firebase

使用Swift 3调试Firebase,swift,xcode,swift3,push-notification,google-cloud-messaging,Swift,Xcode,Swift3,Push Notification,Google Cloud Messaging,我正在调试为什么我无法在iPhone上从firebase获取消息, 我已连接到FCM服务器,并且我还订阅了一个主题,但是,当我尝试打印从FCM接收的数据时,我得到的值为零 这是我从谷歌教程中得到的代码,它被执行了,这是否意味着应用程序被正确地通知FCM上有一个新的主题 另外,我如何调试以查看在设置FCM时是否存在错误 谢谢 func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notificatio

我正在调试为什么我无法在iPhone上从firebase获取消息, 我已连接到FCM服务器,并且我还订阅了一个主题,但是,当我尝试打印从FCM接收的数据时,我得到的值为零

这是我从谷歌教程中得到的代码,它被执行了,这是否意味着应用程序被正确地通知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)

}

请尝试使用此代码并进行调试

 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)
    }

感谢您的建议,该方法不会被调用。你知道为什么吗?你试过这个示例了吗?当我创建了一个新的应用程序并建立了自己的firebase项目时,我能够让它工作。我收到另一个人负责的firebase项目的通知。据我所知,我得到了GoogleService-Info.plist,一切都是正确的。这个Bundle\u ID匹配&我给了他们.p8身份验证密钥。我仍然在DidReceiveEmotentification方法中获得消息ID:nil,除了我似乎连接并获得Firebase令牌之外。有进一步的想法吗?顺便说一句,我收到了一个通知。这是我为后台抓取而创建的,但不再使用。我没有打任何电话或设置通知,但它仍然会弹出。这些可能有某种关联吗&你知道为什么我会弹出这个通知,即使设置它的代码没有被调用吗?