如何处理这种警告

我用过

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

最佳答案

您真的要使用remoteMessage: MessagingRemoteMessage吗?
就我而言,在MessagingDelegate上,我唯一需要做的就是获取fcmToken(Firebase注册 token ),我完全删除了remoteMessage: MessagingRemoteMessage

extension AppDelegate: MessagingDelegate{

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

        let dataDict:[String: String] = ["token": fcmToken]

        firebaseData.fcmToken = fcmToken

        NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
    }
}

关于swift - “MessagingRemoteMessage”已弃用: FCM direct channel is deprecated,,请使用APN进行下游消息处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62079361/

10-11 06:25