Notification When App Is Killed

Push notification with title and description when the app is killed.

Credit to gdelataillade

iOS Anroid

Getting Started

iOS

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

How to use

setNotificationOnKillService:

final _notificationWhenAppIsKilledPlugin = NotificationWhenAppIsKilled();

await _notificationWhenAppIsKilledPlugin.setNotificationOnKillService(
  ArgsForKillNotification(
      title: 'The app is killed',
      description:
          'You can see this notification when the app is killed'),
)

cancelNotificationOnKill:

final _notificationWhenAppIsKilledPlugin = NotificationWhenAppIsKilled();

await _notificationWhenAppIsKilledPlugin
              .cancelNotificationOnKillService()
)

Credit

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

Notes

Checking this package and the onKill notification will only work under release and not under dabug