How to handle app uninstallation in Flutter/Dart?

Viewed 3112

Can anyone tell me if it is possible in Flutter or more generally in mobile development to handle when the user uninstalls the app so that we can perform some actions? I know that we can easily detect when the app switch to the background but I don't figure out if detecting the uninstallation is actually possible.

3 Answers

for iOS you need a APNs (Apple Push Notification service), this way says you that the token is invalid, so, it mean that the device already hasn't the app

check out: How To Track App Uninstall Effectively

@Nuqo is right. There is not a quick way to handle the uninstallation of the app. But you can design a notification system, and push notifications periodically. Firebase will respond error message with "NotRegistered". This means the user is uninstalled your app.

Read more from the official document.

You can do operations while the application is in the background. location tracking, sending requests to any service. You can do what you can do in general android and ios applications. but there are some missing parts. You may need to use packages. some paid.

   @override
   void didChangeAppLifecycleState(AppLifecycleState state) async {
      if (state == AppLifecycleState.resumed) {
         print("user came back to application");
          } else if (state == AppLifecycleState.inactive) {
          print("user within the application");
        } else if (state == AppLifecycleState.paused) {
        print("user threw into the background");
       }
  }
Related