MissingPluginException(No implementation found for method getToken on channel plugins.flutter.io/firebase_messaging)

3,758

Please make sure you have implemented following steps:

1: Add dep in pubspecs.yaml

firebase_core: // latest version
firebase_messaging: // latest version

2: Add dependency & service in the app build.gradle file.

dependencies {

 implementation platform('com.google.firebase:firebase-bom:26.5.0')
 
 implementation 'com.google.firebase:firebase-messaging'
 
}

apply plugin: 'com.google.gms.google-services'

3: proper google-service.json under app directory only

4: Initialization in main.dart

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

5: Add this code in your main class or 1st executing class

FirebaseMessaging.instance.getToken().then((token){
  print("token $token");
}); 
Share:
3,758
Tamim Chowdhury
Author by

Tamim Chowdhury

Updated on December 27, 2022

Comments

  • Tamim Chowdhury
    Tamim Chowdhury over 1 year

    On my release version of my flutter android app I am getting this error.

    I have tried:

    Updating the SHA-1 Key from Google Play Console in Firebase Updating google-services.json Rebuilding and rolling out.

    I still get this error. I have INTERNET_PERMISSIONS enabled and cleartext=true as well.

    App works fine in iOS and android debug mode as well.

    2021-02-15 00:47:37.450 2888-2932/? E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method configure on channel plugins.flutter.io/firebase_messaging) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157) 2021-02-15 00:47:37.450 2888-2932/? E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getToken on channel plugins.flutter.io/firebase_messaging) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157) #1 FirebaseMessaging.getToken (package:firebase_messaging/firebase_messaging.dart:146)

  • Tamim Chowdhury
    Tamim Chowdhury about 3 years
    I already have implementation 'com.google.firebase:firebase-messaging:20.1.0'
  • Priyesh
    Priyesh about 3 years
    can you add logs from installing app to the error you are receiving? So i can understand exact issue
  • Priyesh
    Priyesh about 3 years
    sorry i forgot to mention this. Did you initialize firebase app like this ? Firebase.initializeApp()
  • Tamim Chowdhury
    Tamim Chowdhury about 3 years
    No, where would I initialize it?
  • Priyesh
    Priyesh about 3 years
    @TamimChowdhury ive updated my answer with step 4 : Initialization, Please check it
  • Akah
    Akah over 2 years
    In the version of firebase you are mentioning, the FirebaseMessaging() is deprecated in favor of FirebaseMessaging.instance or FirebaseMessaging.instanceFor() instead.
  • Priyesh
    Priyesh over 2 years
    thanks @Akah I will correct it