gpt4 book ai didi

ios - 如何处理 Could not cast Appdelegate to FIRMessagingDelegate

转载 作者:搜寻专家 更新时间:2023-11-01 06:52:44 24 4
gpt4 key购买 nike

if #available(iOS 10.0, *) 
{
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]

UNUserNotificationCenter.current().requestAuthorization(

options: authOptions,
completionHandler: {_, _ in })
// For iOS 10 data message (sent via FCM

Messaging.messaging().delegate = (self as! MessagingDelegate)

Couldn't cast value from Appdelegate to FIRMessagingDelegate

最佳答案

你需要在类行中遵守协议(protocol)

class AppDelegate: UIResponder, UIApplicationDelegate,FIRMessagingDelegate {

因为这个转换 (self as!MessagingDelegate) 会崩溃,然后将其替换为

Messaging.messaging().delegate = self 

关于ios - 如何处理 Could not cast Appdelegate to FIRMessagingDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56022109/

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