swift 2.0中的FCM推送通知错误

时间:2017-02-07 14:39:42

标签: ios swift firebase firebase-cloud-messaging

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"

2 个答案:

答案 0 :(得分:0)

看起来Google文档已过时。

请在终端中运行以下命令:

pod repo update

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

pod update

(如果有帮助,请将此标记为解决方案)

答案 1 :(得分:0)

试试这个:

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

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