FIRMessagingDelegate的消息:didReceiveMessage:未实现 - Firebase 4.1.1 - Swift 3

Moh*_*zat 1 firebase appdelegate swift3 firebase-cloud-messaging ios10

我将Firebase升级v3到了,v4但是在接收消息方面遇到了一些问题,我收到了此警告:

[Firebase/Messaging] [I-FCM002019] FIRMessaging收到的数据消息,但是FIRMessagingDelegate的消息:didReceiveMessage:未实现

我知道我应该实现这个方法:

public func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage){
    print(remoteMessage.appData)
            //let title = remoteMessage.appData[("data"): {"title"}]
           var title = "New Request"

            for value in remoteMessage.appData{
                if let value = value as?  [AnyHashable:Any]{
                print(value)
                }
            }
            let message = "okay"
            print(message)
             self.showAlertAppDelegate(title: title ,message:message ,buttonTitle:"ok",window:self.window!)
            print(title, message)

}
Run Code Online (Sandbox Code Playgroud)

但是我仍然有警告,所以我应该采取更多行动吗?

Moh*_*zat 6

我发现了问题,就是我忘记了这一行

Messaging.messaging().delegate = self
Run Code Online (Sandbox Code Playgroud)

在这个方法中:

func application(_ application: UIApplication,
               didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {}
Run Code Online (Sandbox Code Playgroud)