Push notification when app is killed
Push notification with title and description when the app is killed.
Credit to gdelataillade
iOS | Anroid |
---|---|
RPReplay_Final1695065849.mp4
|
screen-20230919-161310.1.mp4
|
You will need notification permission so add this to your ios/Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
# dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
]
end
end
end
final _notificationWhenAppIsKilledPlugin = NotificationWhenAppIsKilled();
await _notificationWhenAppIsKilledPlugin.setNotificationOnKillService(
ArgsForKillNotification(
title: 'The app is killed',
description:
'You can see this notification when the app is killed'),
)
final _notificationWhenAppIsKilledPlugin = NotificationWhenAppIsKilled();
await _notificationWhenAppIsKilledPlugin
.cancelNotificationOnKillService()
)
Tahnks to gdelataillade, most of this code is his. Checkout his article in Medium: https://medium.com/@gdelataillade/displaying-a-notification-when-your-flutter-app-is-killed-4ef25cc3f193
Checking this package and the onKill notification will only work under release and not under dabug