'No implementation found for method getApplicationSupportDirectory on channel plugins.flutter.io/path_provider using java (not using kotlin)
I am using new flutter version 2.2.3 and firebase_messaging 10.0.5 plugin.. I have implemented the FCM services. I have got the FCM in background but when FCM is processed. it shows error No implementation found for method getApplicationSupportDirectory on channel plugins.flutter.io/path_provider
eg code for firebase implementation using: this code is in initState()
var android = new AndroidInitializationSettings("mipmap/logo_original");
var ios = new IOSInitializationSettings();
var platform = new InitializationSettings(android : android, iOS: ios);
flutterLocalNotificationsPlugin.initialize(platform, onSelectNotification: onSelectNotification);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseNotifications().setUpFirebase(flutterLocalNotificationsPlugin);
_firebaseMessagingBackgroundHandler method implemetation"
if (message != null) {
await Firebase.initializeApp();
Map<String, dynamic> messageData = message.data;
print('on onBackgroundMessageHandler_ new $messageData');
FirebaseNotifications.myBackgroundMessageHandler_(messageData);
}
Firebase firebaseCloudMessagingListeners method implementation
FirebaseMessaging.instance.getInitialMessage().then((RemoteMessage message) {
print('FirebaseMessaging.instance.getInitialMessage()');
if(message != null){
print('FirebaseMessaging.instance.getInitialMessage() $message');
processAndShowNotification(message, flutterLocalNotificationsPlugin);
}
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message onMessage.listen in the foreground!');
if(message != null){
processAndShowNotification(message, flutterLocalNotificationsPlugin);
}
});
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
print('Got a message onMessageOpenedApp.listen');
if(message != null){
processAndShowNotification(message, flutterLocalNotificationsPlugin);
}
});
while saving data in to database gets error No implementation found for method getApplicationSupportDirectory on channel plugins.flutter.io/path_provider.
documentsDirectory = await getApplicationSupportDirectory();
String dbPath = join(documentsDirectory.path, "dbName.db");
var database = await openDatabase(dbPath,
onOpen: (db) {},
version: <_databaseVersion>, // (eg: 1)
onCreate: _onCreate,
onUpgrade: _onUpgrade
);
I Need to save the data in to local data base (sqlite database)
Application.java file
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
this.registerChannel();
}
@Override
public void registerWith(PluginRegistry registry) {
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
FlutterLocalNotificationsPlugin.registerWith(registry.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
FlutterRingtonePlayerPlugin.registerWith(registry.registrarFor("io.inway.ringtone.player.FlutterRingtonePlayerPlugin"));
SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin"));
}
private void registerChannel(){
int important = 1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//
CharSequence name = getString(R.string.default_notification_channel_id);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
String chanel_name = getString(R.string.default_notification_channel_id);
NotificationChannel channel1 = new NotificationChannel("default", "default", importance);
channel1.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel1);
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|