Sai*_*nth 11 ios firebase visual-studio-code flutter
我正在 Flutter/Firebase 中制作应用程序,但在我的 Visual Studio 代码终端上遇到以下错误:-
Xcode build done.                                           522.2s
6.26.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
6.26.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications 
proxy enabled, will swizzle remote notification receiver handlers. If you'd 
prefer to manually integrate Firebase Messaging, add 
"FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow 
the instructions at:
https://firebase.google.com/docs/cloud- 
messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
Waiting for iPhone 11 to report its views...                         9ms
Syncing files to device iPhone 11...                               610ms
关于如何解决这个问题的任何想法......????
Sai*_*nth 33
我解决了这个问题。如果您在 AppDelegate.swift 中使用 swift,请确保您已按该顺序添加以下内容:
FirebaseApp.configure() //add this before the code below
GeneratedPluginRegistrant.register(with: self)
如果您使用带有objective-c 的flutter,请将以下内容添加到您的appdelgate.m 文件中:-
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure]; //add this right after the above
Cur*_*art 10
这是初始化 Firebase 的另一种方法,它是通过编辑 main.dart 来完成的。
这可能是首选解决方案,因为在初始化所有应用程序小部件之前,它不会初始化 Firebase。我遇到过一些小部件无法工作的情况,因为它们对 Firebase 实例的引用为空。
WidgetsFlutterBinding.ensureInitialized(); 是进行类初始化所必需的。
尽管 Sai 给出的解决方案有效,但我怀疑由于微妙的初始化问题,它并不总是有效。
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}
随着添加FirebaseApp.configure(),不要忘记import Firebase。
AppDelegate.swift 文件应该像这样开始:
import UIKit
import Firebase
我还收到“尚未配置应用程序”消息,这只是一个警告,在调用
await FirebaseMessaging.instance.requestPermission并接受权限后(IOS 需要用户的权限),我会收到 FCM 的通知。当然,在我的主函数中,我需要添加这些(用于新的 Dart 初始化)。
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);
不再需要在 AppDelegate 中添加“GoogleService-Info” FirebaseApp.configure(),因为 FlutterFire 现在支持直接从 Dart 进行初始化!新的 Dart 初始化文档在这里:https ://firebase.flutter.dev/docs/overview/
| 归档时间: | 
 | 
| 查看次数: | 6868 次 | 
| 最近记录: |