为什么我的 FCM 通知没有显示在 iOS 中(抖动)
Why aren't my FCM notifications showing in iOS (flutter)
我正在做一个 flutter 应用程序,当一些用户做某事时,另一个用户会收到推送通知(来自 firebase 消息传递)。在 android 中它工作正常,但在 iOS 中我根本无法完成这项工作。
我做过的事情:
- 在apple developers中生成key并导入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)
}
}
上面有什么错误吗?我该如何解决这个问题?
如果需要,我可以 post 代码的其他部分。
你插入了吗:
<key>FirebaseScreenReportingEnabled</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>
进入info.plist?
我正在做一个 flutter 应用程序,当一些用户做某事时,另一个用户会收到推送通知(来自 firebase 消息传递)。在 android 中它工作正常,但在 iOS 中我根本无法完成这项工作。
我做过的事情:
- 在apple developers中生成key并导入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)
}
}
上面有什么错误吗?我该如何解决这个问题? 如果需要,我可以 post 代码的其他部分。
你插入了吗:
<key>FirebaseScreenReportingEnabled</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>
进入info.plist?