zey
zey

Reputation: 297

Flutter - How can I follow the uninstall of the application?

I am developing a flutter app. I want to update its status in my database when the user deletes the app from own phone. How can I follow these changes? Is it possible on flutter?

Upvotes: 1

Views: 944

Answers (2)

David Ordine
David Ordine

Reputation: 21

Unfortunately there's no easy way to do that, but @payam-asefi answer doesn't look right.

device_apps wouldn't help to detect it's own app deletion since flutter framework wouldn't even be running on on app deletion.

Here's two possible solutions.

1 - Harder/complete one: This one offers full tracking of individual users/devices

2 - The way I did in one of the apps I worked on (only works on android):

  • Added Firebase to our Flutter app
  • Added Firebase analytics

By default analytics already reports some events, including app_remove (android only)

  • When the user logs in, set some key informations with FirebaseAnalytics setUserProperty method.

Example:

analytics.setUserProperty(name: 'id', value: user.id);
  • Marked app_remove event as a conversion event (Yes I know this is a work around). This needs to be done since cloud functions is only triggered by conversion events.

  • On the same Firebase project, created a cloud function that will be triggered by app_remove and will call an API endpoint to update the user status.

On the cloud function, you can check the event name and user property (assuming using JS) like this:

const eventName = event.eventDim[0].name;
const userId = event.userDim.userProperties.id;

Upvotes: 0

Payam Asefi
Payam Asefi

Reputation: 2757

There is no way to do it in iOS, but for android, you can use device_apps package to get the current list of installed apps and then compare it to the previously fetched data.

First, add this to your androids manifest file:

<manifest...>

    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />

</manifest>

and then use it:

List<Application> apps = await DeviceApps.getInstalledApplications();

Upvotes: 1

Related Questions