-
Notifications
You must be signed in to change notification settings - Fork 124
How to Get OnDestroyed Method When User Swipe up App #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can't get |
You can use this method if you don't mind if the foreground service is killed.
<service
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:stopWithTask="true" />
Future<void> _initForegroundTask() async {
await FlutterForegroundTask.init(
androidNotificationOptions: AndroidNotificationOptions(
channelId: 'notification_channel_id',
channelName: 'Foreground Notification',
channelDescription: 'This notification appears when the foreground service is running.',
channelImportance: NotificationChannelImportance.LOW,
priority: NotificationPriority.LOW,
isSticky: false,
),
iosNotificationOptions: const IOSNotificationOptions(),
foregroundTaskOptions: const ForegroundTaskOptions(
interval: 5000,
autoRunOnBoot: true,
allowWifiLock: true,
),
printDevLog: true,
);
}
class FirstTaskHandler extends TaskHandler {
@override
Future<void> onStart(DateTime timestamp, SendPort? sendPort) async {
}
@override
Future<void> onEvent(DateTime timestamp, SendPort? sendPort) async {
}
@override
Future<void> onDestroy(DateTime timestamp) async {
// here
}
} |
@Dev-hwang , thanks for reply, i dont need foreground services when user swipe up the app , its just , as long as user using that app , and its still in taskbar, becuase when user swipes up the app with your package , app is not disconnecting with bluetooth(which is connected with a stream) , and becuase of that , when user opens the app , that bluetooth device is still connected , but app as usually opens the scan page( and that bluetooth device will not be discoverable , until i break connection manually from mobile) , so i want this service just to keep bluetooth task in background as long as app is in Taskbar of Mobile , and user can just swipe up and break all connections and stop app services completly , so can i achieve this with your package , will try this above solution , if Ondestroy worked , will close all connection Streams in that |
@Dev-hwang , above solution worked perfectly , Thanks |
Hey , can we have a method which will be called just when app is about to Terminate
The text was updated successfully, but these errors were encountered: