gpt4 book ai didi

ios - FCM token 不调用 didReceiveRegistrationToken

转载 作者:行者123 更新时间:2023-11-29 05:36:45 31 4
gpt4 key购买 nike

您好,在我的应用程序中使用 FCM

当我尝试读取 FCM token 时,即使编译器不调用此委托(delegate)方法,也请提供帮助。

当我放置中断并检查此方法时,不要使用 ios11 swift4 调用我

extension AppDelegate: MessagingDelegate{

func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")

let dataDict:[String: String] = ["token": fcmToken]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
}

func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) {
print("Message data:", remoteMessage.appData)
}
}

最佳答案

 didReceiveRegistrationToken

是一个委托(delegate)函数。它将在收到 Firebase 的 token 后被调用。如果没有被调用,请确保您已遵循 AppDelegate 中的代码

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
return true
}

通过 Messaging.messaging().delegate = self,我们注册 AppDelegate 以接收来自 Firebase 的方法调用

关于ios - FCM token 不调用 didReceiveRegistrationToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56968730/

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