Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Make sure to call FirebaseApp.initializeApp(Context) first. #66

Open
jvondermarck opened this issue Jul 22, 2024 · 2 comments
Open

Comments

@jvondermarck
Copy link

jvondermarck commented Jul 22, 2024

E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): Failed to handle message
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process <here my applicationID>. Make sure to call FirebaseApp.initializeApp(Context) first.
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:183)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at com.google.firebase.messaging.FirebaseMessaging.getInstance(com.google.firebase:firebase-messaging@@23.0.0:1)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at uk.orth.push.PushHostHandlers.getToken(PushHostHandlers.kt:52)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at uk.orth.push.serialization.PushHostApi$Companion.setUp$lambda-3$lambda-2(PushApi.kt:340)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at uk.orth.push.serialization.PushHostApi$Companion.$r8$lambda$DaI8nyMPCGeQZ28OWpPjC3ArNyU(Unknown Source:0)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at uk.orth.push.serialization.PushHostApi$Companion$$ExternalSyntheticLambda1.onMessage(Unknown Source:2)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
E/BasicMessageChannel#dev.flutter.pigeon.push_platform_interface.PushHostApi.getToken(27489): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)

Why do I get the error when I run the code :

  void initPushNotification() async
  {
    Push.instance.requestPermission();

    pushToken = await Push.instance.token.then((value) {
      pushToken = value;
      debugPrint("Push token: $pushToken");
    }, onError: (error) {
      debugPrint("Error getting push token: $error");
    });
 }

In your example code, you did not do this "FirebaseApp.initializeApp(Context)" so that is weird...

@ProfJackCZ
Copy link

I've encountered the same issue. It looks related to the new com.google.gms:google-services version, which may have some breaking changes.
A temporary solution that worked for me is using an older version of google services plugin.
Try changing the version of com.google.gms.google-services to 4.3.15 in android/build.gradle

@jvondermarck
Copy link
Author

Thank you @ProfJackCZ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants