Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.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
Ios 收到推送通知时获取系统警告_Ios_Swift_Push Notification - Fatal编程技术网

Ios 收到推送通知时获取系统警告

Ios 收到推送通知时获取系统警告,ios,swift,push-notification,Ios,Swift,Push Notification,我在我的项目中实现了推送通知,现在的问题是,在调试的登台环境中,会收到通知,当我点击它时,它会进入我希望它进入的视图,但在生产应用程序中,当我点击nofification时,我会在我的xcode控制台中得到它 警告:UnuseNotificationCenter代理收到对的呼叫 -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: 但从未调用完成处理程序 我不知道为什么会有这种行为,欢迎任何帮助

我在我的项目中实现了推送通知,现在的问题是,在调试的登台环境中,会收到通知,当我点击它时,它会进入我希望它进入的视图,但在生产应用程序中,当我点击nofification时,我会在我的xcode控制台中得到它

警告:UnuseNotificationCenter代理收到对的呼叫 -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: 但从未调用完成处理程序

我不知道为什么会有这种行为,欢迎任何帮助

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfo
        extractUserInfo(userInfo: userInfo)
    }

    func extractUserInfo(userInfo: [AnyHashable: Any]) {
        log("FirebaseTest App already open blllll \(userInfo)", .fuck)
        let aps = userInfo["aps"] as? NSDictionary
        log("FirebaseTest App already open aps \(aps)", .json)
////        let info = userInfo as? NSDictionary
        if let type = userInfo["type"] as? String {
            Storage.instance.savePush(type)
            if type == "new_property" {
                if let meta = userInfo[AnyHashable("meta")] as? String {
                    if let data = meta.data(using: .utf8) {
                        do {
                            if let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any] {
                                guard let propertyId = json["property_id"] as? String, let id = Int(propertyId) else {return}
                                NotificationEvent.isFromNotification.accept(true)
                                NotificationEvent.id.accept(id)
                            } else {
                                print("JSON is invalid")
                            }
                        } catch {
                            print("Exception converting: \(error)")
                        }
                    }
                }
            } 
        }

    }

只需在任务完成后调用完成处理程序,如下所示

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    extractUserInfo(userInfo: userInfo) /// your task
    completionHandler() /// notify system
}