FIRMessaging接收无效状态2 swift的通知

时间:2017-01-06 16:35:56

标签: swift firebase push-notification swift3 firebase-cloud-messaging

我从Postman发送以下有效载荷:

{
    "to" : "serverkey", 
    "data" : {"score":"5"},
    "content_available": true,
    "notification" : {
        "body": "sample21 "
    },
    "priority" : "high"
}

并收到错误:

<FIRMessaging/WARNING> FIRMessaging receiving notification in invalid state 2

我根据文档使用content_available,所以我不知道问题是什么?

编辑:添加到用户在评论中提出的方法

 func application(_ application: UIApplication,  didReceiveRemoteNotification userInfo: [NSObject : AnyObject],  fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

        print("in didReceiveRemoteNotification")
        print("%@", userInfo)

        DispatchQueue.main.async {
            completionHandler(UIBackgroundFetchResult.newData)
        }
    }

    extension AppDelegate : FIRMessagingDelegate {
        // Receive data message on iOS 10 devices.
        func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
            print("in applicationReceivedRemoteMessage")
            print("%@", remoteMessage.appData)

        }
    }

0 个答案:

没有答案