Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package not found in Application.java in flutter FlutterFirebaseMessaging plugin

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                                                                                                            
like image 775
kunaljosh369 Avatar asked Nov 06 '22 13:11

kunaljosh369


1 Answers

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

like image 104
Mahmoud Abu Alheja Avatar answered Nov 14 '22 21:11

Mahmoud Abu Alheja