Swift 2.0中的FCM推送通知错误

iqjalb3h  于 2023-05-27  发布在  Swift
关注(0)|答案(2)|浏览(180)
if #available(iOS 10.0, *) {
    let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
    UNUserNotificationCenter.current().requestAuthorization(
        options: authOptions,
        completionHandler: {_, _ in }
    )

    // For iOS 10 display notification (sent via APNS)
    UNUserNotificationCenter.current().delegate = self
    // For iOS 10 data message (sent via FCM)
    FIRMessaging.messaging().remoteMessageDelegate = self //ERROR THIS LINE

}
else {
    let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
    application.registerUserNotificationSettings(settings)
}

将委托设置为self时出错。“FIRMessing没有成员remoteMessageDelegate”

wz3gfoph

wz3gfoph1#

试试这个:

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate{
}

//MARK: FIRMessaging Delegate
func applicationReceivedRemoteMessage(remoteMessage: FIRMessagingRemoteMessage){  
}
rryofs0p

rryofs0p2#

看来Google的文档已经过时了。
请在您的终端中运行以下命令:

pod repo update

然后转到您的项目文件夹并运行

pod update

相关问题