不推荐使用:不推荐使用 FCM 直接通道,请使用 APNs 进行下游消息处理

Posted

技术标签:

【中文标题】不推荐使用:不推荐使用 FCM 直接通道,请使用 APNs 进行下游消息处理【英文标题】:is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handlind 【发布时间】:2020-10-12 23:46:05 【问题描述】:

我在为 ios 构建时收到这些消息,它成功但 IOS 通知不起作用,我收到 FCM 未注册的消息/注册令牌,所以我认为这篇文章可能与此错误有关。

这是说我的注册令牌没有注册。在查看了 firebase 文档后,我看到了:https://firebase.google.com/docs/cloud-messaging/send-message#admin_sdk_error_reference

消息/注册令牌未注册:

提供的注册令牌未注册。以前有效的注册令牌可能因多种原因而被取消注册,包括:

客户端应用从 FCM 中取消注册 客户端应用程序已自动取消注册。(如果用户卸载应用程序,或者在 iOS 上,如果 APNS 反馈服务报告 APNS 令牌无效,则会发生这种情况。) 注册令牌已过期。 (例如,Google 可能决定刷新注册令牌,或者 iOS 设备的 APNS 令牌可能已过期。) 客户端应用程序已更新,但新版本未配置为接收消息。 对于所有这些情况,请移除此注册令牌并停止使用它来发送消息。

但我觉得我已经满足了所有要求(APNS 已经配置并添加到 Firebase 控制台中)

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:195:43: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]

- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage 
                                          ^


⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:307:24: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]

    didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage 
                                                      ^



⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:141:30: 'shouldEstablishDirectChannel' is deprecated: FCM direct channel is deprecated, please use APNs channel for downstream message delivery. [-Wdeprecated-declarations]

    [FIRMessaging messaging].shouldEstablishDirectChannel = true;
                                                      ^


⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:196:52: 'appData' is deprecated [-Wdeprecated-declarations]

  [self didReceiveRemoteNotification:remoteMessage.appData];
                                                               ^


⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:306:1: implementing deprecated method [-Wdeprecated-implementations]

- (void)messaging:(FIRMessaging *)messaging
                                                           ^


⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:308:63: 'appData' is deprecated [-Wdeprecated-declarations]

  [_channel invokeMethod:@"onMessage" arguments:remoteMessage.appData];
^


⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:195:43: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]

- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage 
                                                           ^

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:307:24: 'FIRMessagingRemoteMessage' is deprecated: FCM direct channel is deprecated, please use APNs for downstream message handling. [-Wdeprecated-declarations]

    didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage 
                                                      ^

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:141:30: 'shouldEstablishDirectChannel' is deprecated: FCM direct channel is deprecated, please use APNs channel for downstream message delivery. [-Wdeprecated-declarations]

    [FIRMessaging messaging].shouldEstablishDirectChannel = true;
                                                      ^

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:196:52: 'appData' is deprecated [-Wdeprecated-declarations]

  [self didReceiveRemoteNotification:remoteMessage.appData];
                                                               ^

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:306:1: implementing deprecated method [-Wdeprecated-implementations]

- (void)messaging:(FIRMessaging *)messaging

⚠️  /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-6.0.16/ios/Classes/FLTFirebaseMessagingPlugin.m:308:63: 'appData' is deprecated [-Wdeprecated-declarations]

  [_channel invokeMethod:@"onMessage" arguments:remoteMessage.appData];
^


⚠️  /Users/builder/clone/ios/Runner/AppDelegate.swift:11:58: conditional cast from 'AppDelegate' to 'UNUserNotificationCenterDelegate' always succeeds

      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
^  ~~~~

【问题讨论】:

直接通道已被弃用,但在 Firebase 6 中仍然有效。它与您的问题无关。 【参考方案1】:

设备令牌会随着时间而改变,因此如果您存储设备令牌,则需要确保每次启动应用时您都refresh the token。

【讨论】:

以上是关于不推荐使用:不推荐使用 FCM 直接通道,请使用 APNs 进行下游消息处理的主要内容,如果未能解决你的问题,请参考以下文章

Swift 4:不推荐使用 substring(with:)':请使用字符串切片下标 [重复]

nginx 不推荐使用“ssl”指令,请使用“listen ... ssl”

弃用警告:不推荐使用计数。请改用 Collection.count_documents

JavaScript 为啥不要使用 eval

FCM - 为啥在较新的 Firebase Admin SDK 中不再支持 FCM 直接通道?

node-express 错误:表示不推荐使用 res.send(status):请改用 res.sendStatus(status)