gpt4 book ai didi

ios - 通知未通过 Firebase 控制台发出

转载 作者:行者123 更新时间:2023-11-30 12:26:30 26 4
gpt4 key购买 nike

enter image description here enter image description here

我已针对上述问题尝试了所有可能的解决方案,但仍未通过 Firebase 控制台向我的设备发送通知。请提出建议。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FIRApp.configure()
if let remoteNotification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary {

self.handleNotification(remoteNotification as! [NSObject : AnyObject])
}
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()

// Add observer for InstanceID token refresh callback.
NSNotificationCenter
.defaultCenter()
.addObserver(self, selector: #selector(AppDelegate.tokenRefreshNotificaiton),
name: kFIRInstanceIDTokenRefreshNotification, object: nil)
return true }
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {


FIRMessaging.messaging().appDidReceiveMessage(userInfo)



NSNotificationCenter.defaultCenter().postNotificationName("reloadTheTable", object: nil)


}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {

FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox)
}
func tokenRefreshNotificaiton(notification: NSNotification) {
guard let refreshedToken = FIRInstanceID.instanceID().token()
else {
return
}


print("InstanceID token: \(refreshedToken)")

utill.tokenDefault.setValue(refreshedToken, forKey: "tokenId")

connectToFcm()
}

调试器中还显示了一些 Firebase 警告:

最佳答案

如果您从 Xcode 8 或更高版本部署应用程序,请确保您已从图中所示的项目目标功能部分启用了推送通知功能。 enter image description here

关于ios - 通知未通过 Firebase 控制台发出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44132530/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com