Saturday, 6 August 2016

Tracking Uninstalls on Android

Is it possible to detect Android app UNINSTALL?
Well lets take an example, You launch an app, invest a lot of resources, spend like crazy on marketing, add all types of analytics to track users' every click and analyze it. One day, a user uninstalls your app. You don't know why he did it, you don't have any way to get back to him and ask for a feedback?
Users are the most important data/resource for an app to make its user database based upon which the particular application is considered to be popular. In such a case you would not like any of your user to stop using your application or if a user stops using your application there must be a way to hold him back to the app or at-least ask him the reason for stop using the app so that you can work on that point to improve.
For this, neither the operating system sends a trigger to your App at uninstall time nor it is available from the Appstore.
Solution to this problem is that there must be a way which can be used to see who is uninstalling your app and that way is the use of Push notification. Yes, use of push notification at an optimum frequency can help you track uninstalls. Once you know who has uninstalled, you can make use of your user data stored in your database to get in touch with that user.

Workaround:-
Send a push notification to all users at some frequency (say, daily). Send a special parameter in the body to determine that the push notification is only for tracking uninstalls. You shouldn't show anything on the device for such kind of notification, just process it silently.
Suppose, you send a push notification as follows:
{
"registration_ids": [
"csHKDjhH8n3Knr38nn8wsq88e2BnwujulIYhhHhHhiu89trerechbWQd3zh",
"fFN9eAHFqdQ:7VhMi DrndidjrxV25VM8ZglEsoio-mMFYRBHygCG7RkXRPA5M"
],
"data": {
"type": "track-uninstall"
}
}

The second id is of a device from which app has been removed. Let's check the response we get from GCM.
{
"multicast_id": 5559150596267635443,
"success": 1,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1438339632512460 %2930a2c7f9fd7ecd"
},
{
"error": "NotRegistered"
}
]
}

As you can clearly see, for the second id, it says that the device is not registered. You can find the user corresponding to the id from your database and try to get in touch with her/ him.
The next step would be to get a callback from the push notification service, find the user this id maps to in your database and let your server logic to handle that user now.

The complete flow of this procedure can be understood in a better way as follows:

A client app can be automatically unregistered after it is uninstalled. However, this process does not happen immediately. What happens in this scenario is:

  • The end user uninstalls the client app.
  • The app server sends a message to GCM connection server.
  • The GCM connection server sends the message to the GCM client on the device.
  • The GCM client on the device receives the message and detects that the client app has been uninstalled; the detection details depend on the platform on which the client app is running.
  • The GCM client on the device informs the GCM connection server that the client app was uninstalled.
  • The GCM connection server marks the registration token for deletion.
  • The app server sends a message to GCM.
  • The GCM returns a NotRegistered error message to the app server.
  • The app server should delete the registration token.

Note that it might take a while for the registration token to be completely removed from GCM. Thus it is possible that messages sent during step 7 above get a valid message ID as a response, even though the message will not be delivered to the client app. Eventually, the registration token will be removed and the server will get a NotRegistered error, without any further action being required from the app server. After this let your server logic to handle that user now to get hold of him back to the application.

References:
https://developers.google.com/cloud-messaging/registration#how-uninstalled-client-app-unregistration-works
https://leftshift.io/mobile-tracking-uninstalls-on-ios-and-android

Always code to make it better..!!



No comments:

Post a Comment