【问题标题】:FCM Notification is not coming in iOS 12iOS 12 中未提供 FCM 通知
【发布时间】:2018-10-04 08:13:58
【问题描述】:

我想使用 FCM 在我的应用中仅显示默认 UI 通知,Apple Push Notification 在所有 iOS 版本中都可以正常工作,但在 iOS 12 中我没有收到通知。

有人能帮我在 iOS 12 中显示默认 UI 通知吗?我必须对代码或 .plist 进行哪些更改?

【问题讨论】:

  • 您是否尝试在 iOS 中降级 Firebase SDK 版本?你用的是哪一个?我在这里发现了一个类似的案例:stackoverflow.com/questions/46391818/….
  • @NeverHopeless 以前我使用的是 Firebase SDK 版本 3,我今天更新了 SDK,我在 iOS 12 中遇到了同样的问题。通知在 iOS 10 和 11 中工作正常。

标签: ios swift firebase apple-push-notifications firebase-cloud-messaging


【解决方案1】:

您应该检查是否在您的应用委托中获得了设备令牌,如果您没有收到设备令牌,您应该将 APNS 令牌类型更改为其中之一,然后与您的配置同步:

FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: .sandbox)

FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: .none)

FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: .prod)

【讨论】:

  • 我获得了 APNS 和 FCM 的设备令牌,当我通过 pushtry.com 检查我的通知时,我收到了 FCM 消息,但没有调用我的 APN 方法。这仅在 iOS 12 中发生,我在所有版本的 iOS
  • //使用此方法接收iOS 11及以下的通知 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult)) completionHandler {your code here} // #if defined(__IPHONE_12_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0 - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {你的代码在这里}#endif
  • 我正在使用这些所有功能(Swift)。但这些方法没有被调用。
  • 我不确定你是否使用了#if 条件...因为如果你不使用它,方法永远不会调用
猜你喜欢
  • 1970-01-01
  • 2019-08-17
  • 2021-04-17
  • 1970-01-01
  • 2021-01-21
  • 2021-02-11
  • 2017-02-25
  • 1970-01-01
  • 2021-05-11
相关资源
最近更新 更多