【问题标题】:Why aren't my FCM notifications showing in iOS (flutter)为什么我的 FCM 通知没有在 iOS 中显示(颤振)
【发布时间】:2021-04-14 06:25:49
【问题描述】:

我正在做一个颤振应用程序,当一些用户做一些事情时,另一个用户会收到推送通知(来自 firebase 消息传递)。在 android 中它工作正常,但在 iOS 中我根本无法完成这项工作。

我做过的事情:

  • 在苹果开发者中生成密钥并将其导入firebase APN
  • 在 Xcode 中启用了“推送通知、后台模式、后台获取和远程通知”
  • 与 firebase 工作进行连接 (google service.plist)

总而言之,所有与 firebase 的连接在 android 和 iOS 中都可以正常工作,但在 iOS 中不会出现通知。

以下代码来自我的AppDelegate.swift

import UIKit
import Flutter
import Firebase

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    if #available(iOS 10.0, *) {
      // For iOS 10 display notification (sent via APNS)
      UNUserNotificationCenter.current().delegate = self

      let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
      UNUserNotificationCenter.current().requestAuthorization(
        options: authOptions,
        completionHandler: {_, _ in })
    } else {
      let settings: UIUserNotificationSettings =
      UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
      application.registerUserNotificationSettings(settings)
    }

    application.registerForRemoteNotifications()
    FirebaseApp.configure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

上面有什么错误吗?我该如何解决这个问题? 如果需要,我可以发布代码的其他部分。

【问题讨论】:

    标签: ios swift firebase flutter firebase-cloud-messaging


    【解决方案1】:

    你插入了吗:

    <key>FirebaseScreenReportingEnabled</key>
    <true/>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <true/>
    

    进入 info.plist?

    【讨论】:

      猜你喜欢
      • 2021-09-06
      • 2021-10-31
      • 2020-12-27
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      相关资源
      最近更新 更多