Package not found in Application.java in flutter FlutterFirebaseMessaging plugin

2,575

I have faced the same problem and so far I have not found any solution

but If you want just show notification with out handle it in background and just lunch app when click on it

remove FlutterFirebaseMessagingService.setPluginRegistrant(this);and the notification will work fine as Notification messages type

if you don't know about Notification type in fcm

refer to Message types

With FCM, you can send two types of messages to clients:

1- Notification messages, sometimes thought of as "display messages." These are handled by the FCM SDK automatically.

2- Data messages, which are handled by the client app.

so we use Notification messages here until find solution for handle Data messages

Share:
2,575
kunaljosh369
Author by

kunaljosh369

Updated on December 14, 2022

Comments

  • kunaljosh369
    kunaljosh369 over 1 year

    I am working with firebase messaging. I followed the steps as given in readme of the plugin. But my application .java is giving an error.

    Application.java

    package com.app.demoapp;
    import com.transistorsoft.flutter.backgroundfetch.BackgroundFetchPlugin;
    import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
    import io.flutter.app.FlutterApplication;
    import io.flutter.plugin.common.PluginRegistry;
    import io.flutter.plugins.GeneratedPluginRegistrant;
    import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
    
    public class Application extends FlutterApplication implements PluginRegistry.PluginRegistrantCallback {
      public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
        BackgroundFetchPlugin.setPluginRegistrant(this);
      }
    
      @Override
      public void registerWith(PluginRegistry registry) {
        GeneratedPluginRegistrant.registerWith(registry);
      }
    }
    

    Error:

    error: cannot find symbol
        FlutterFirebaseMessagingService.setPluginRegistrant(this);                                                     
                                       ^                                                                               
      symbol:   method setPluginRegistrant(Application)                                                                
      location: class FlutterFirebaseMessagingService                                                                  
    1 error