How to execute a plugin code inside a dart isolate? - flutter

In my app i need to listen to firebase notification. Firebase background notification can be handled by using the onBackgroundMessage. I want to print on a thermal printer as soon as this notification arrives, this requires to call a method from the plugin library inside this background notification handler function, but when calling the method i am getting this error
Unhandled Exception: MissingPluginException(No implementation found for method printLabel on channel bluetooth_print/methods)
How to go about this?

Related

Unable to access the hive box when app is in background in flutter

I am using Hive box to store some key value pairs and want to use those values to filter the incoming push notifications on my flutter project. But this logic works only when the app is in foreground or not closed but if closed it throws this error
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
and shows all the push notifications.
The line of code which throws this error is possbily await Hive.initFlutter(); as this is only using getApplicationDocumentsDirectory under the hood.

Display incoming call notification when flutter app is terminated or in a background

is there a way to display incoming call notifications when the flutter app is terminated or in the background? I tried to use connectyCube package, but too complex. Also, I used the flutter background service to listen to incoming calls with socket.io but the app got crashed when it is launched from the background. I need your guidance.
You can use native code in android for incoming call notification.
For Android you can use HeadsUpNotificationService as we use in native.
And for Ios you can use https://github.com/peerwaya/flutter_call_kit

how to run dart code when receive notification on Terminated state?

I have to post some data to Firebase when user receive notification when app is on killed/Terminated state,
I tried flutter_background_service but that not solved my problem.
I don't want to run my app on background, I just want to run my app on background when I receive notification and after sends data to Firebase close the background thread.
I faced this problem a long time ago. I solved it by using Firebase native instead of Firebase flutter, and pass all my data to/from native using native bridge.
You might be able to use both (flutter for most of the stuff, native for the background stuff), but be prepared for dependency hell and some bizarre behavior on init etc.
Basically when your app is in the background or not running then if firebase notification triggers then the FirebaseMessaging.onBackgroundMessage() method gets called.
So if you want to do something then you can put your code like
/// this method will be called when you receive a message from firebase
/// while your app is not running
/// put this line on your main method
FirebaseMessaging.onBackgroundMessage(_messageHandler);
/// this method should be a top level function
Future<void> _messageHandler(RemoteMessage message) async {
// do what you want
}

How to read sms when flutter app is closed

We are building an app in flutter where we have a requirement to read user sms. We are able to successfully read a message using https://pub.dev/packages/telephony plugin when app is open. This plugin also provided background message handle which we implemented but still we are not able to read message when app is closed. Is there other way to achieve it.
telephony.listenIncomingSms(
onNewMessage: (SmsMessage message) {
// Handle message
},
onBackgroundMessage: backgroundMessageHandler
);
telephony not working if app closed use method channel connect kotlin create BroadcastReceiver create service and registerReceiver

Receiving call same as WhatsApp in Flutter

I am implementing a video call feature in Flutter with the help of Firebase Cloud Messaging,
it's working fine in foreground.
my doubt is
while app is in background I need to get a receiving call same like as WhatsApp in both Android and IOS .... is it possible in flutter?
yes. it is possible by the combination of push notification and flutter_callkeep to show the upcoming call screen.
Or if you want to run the background process you need to refer to Method Channels, and here is a post about creating a service for running app in the background. also background_fetch is a useful package for background process.