我的 Flutter/Firebase 应用程序显示尚未配置任何应用程序

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
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题的任何想法......????

Sai*_*nth 33

我解决了这个问题。如果您在 AppDelegate.swift 中使用 swift,请确保您已按该顺序添加以下内容:

FirebaseApp.configure() //add this before the code below
GeneratedPluginRegistrant.register(with: self)
Run Code Online (Sandbox Code Playgroud)

如果您使用带有objective-c 的flutter,请将以下内容添加到您的appdelgate.m 文件中:-

didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FIRApp configure]; //add this right after the above
Run Code Online (Sandbox Code Playgroud)

  • 好的。这是一件超级有趣(又名奇怪)的事情。我有两个连接到同一个 FireBase 的项目。一个无法构建,我使用了这个解决方案并且它有效。另一个没有 FirebaseApp.configure(),但它也可以工作。我确信有另一种方法可以做到这一点,当我弄清楚时我会报告。 (3认同)
  • (对于 swift)如下所述,您必须在顶部“import Firebase”导入 firebase (3认同)

Cur*_*art 10

这是初始化 Firebase 的另一种方法,它是通过编辑 main.dart 来完成的。

这可能是首选解决方案,因为在初始化所有应用程序小部件之前,它不会初始化 Firebase。我遇到过一些小部件无法工作的情况,因为它们对 Firebase 实例的引用为空。

WidgetsFlutterBinding.ensureInitialized(); 是进行类初始化所必需的。

尽管 Sai 给出的解决方案有效,但我怀疑由于微妙的初始化问题,它并不总是有效。

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}
Run Code Online (Sandbox Code Playgroud)

  • 在 flutter 2.1.0 上对我不起作用。必须按照接受的答案中提到的方式编辑 AppDelegate.swift 。 (6认同)

eld*_*dar 8

随着添加FirebaseApp.configure(),不要忘记import Firebase

AppDelegate.swift 文件应该像这样开始:

import UIKit
import Firebase
Run Code Online (Sandbox Code Playgroud)

  • 你需要告诉它需要放在哪里,否则只有 iOS 开发人员才能理解。 (3认同)

Hie*_*yen 7

我还收到“尚未配置应用程序”消息,这只是一个警告,在调用 await FirebaseMessaging.instance.requestPermission并接受权限后(IOS 需要用户的权限),我会收到 FCM 的通知。当然,在我的主函数中,我需要添加这些(用于新的 Dart 初始化)。

WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);
Run Code Online (Sandbox Code Playgroud)

不再需要在 AppDelegate 中添加“GoogleService-Info” FirebaseApp.configure(),因为 FlutterFire 现在支持直接从 Dart 进行初始化!新的 Dart 初始化文档在这里:https ://firebase.flutter.dev/docs/overview/

  • 你是对的,这个警告只是毫无感情的表现。使用FlutterFire最新版本,我们不再需要手动配置。 (2认同)