[英]Flutter firebase_messaging 6.0.9
我正在嘗試為用 Flutter 編寫的 iOS 應用程序設置推送通知。 我找到了以下包:firebase_messaging 6.0.9 ( https://pub.dev/packages/firebase_messaging )。
我在第 5 點(iOS 設置),這對我來說不是很清楚。 我掙扎的部分是:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
到 iOS 項目的AppDelegate.m/AppDelegate.swift
中的(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法。
我有 AppDelegate.swift 文件,但我不知道把這行代碼放在哪里。 無論我把它放在哪里,應用程序都會崩潰。
我的 App Delegate 文件如下所示:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
我的背景主要是 JavaScript,主要是 React,我對 iOS 或 swift 不太了解,所以在理想的世界中,我很想閱讀更清晰的文檔,以幫助像我這樣的新手使用這個包。 我希望有人確切地知道該做什么,甚至以前使用過這個包。
歡迎任何幫助。 這個包好用嗎? 也許有一個更好的包和更清晰的文檔,你已經成功地使用了? 非常感謝大家的幫助和評論!
如果您的文件是AppDelegate.swift,您只需在 -> Bool {...} 下添加條件。
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
我是撲的新人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.