8

Problem Description:

We have a service which has applications for main mobile OS’s. We use push notifications. When user is log in, we store his device authorization data (lets say token) for later use in the push service. The problem is about few device authorizations for one user and properly keeping them valid when the user uninstall the application.

Example:

I gave my login to system to a few people, in case to try it. They logged in through the mob. application and the system automatically add a few device authorizations into database (tokens). So now we have N device tokens for 1 user. So that if we send push notification everyone will receive it. Now, suppose those who have installed applications want to uninstall it. Without logout they uninstall application through application manager. And at this time we have NOT VALID data for authorized device. And if we try to notify them, notification will be sent nowhere. Which is wrong, and useless work for server. How to let the core know that some of stored data is no longer valid?

Shortly – is there any possibility in Android / iOS to trigger application delete event. If the application is being delete application call server to clean-up data in the storage. Or if the application is open and the user uninstall it, would there onDestroy() trigger fired? Or some other?

I’m not iOS developer, not Android developer, just know a little about second one and nothing of the first. Any advice will be appreciated. Thanks in advance.

devdRew
  • 4,393
  • 3
  • 24
  • 33
  • oh right, you wanted to know about that one to. it doesn't work quite the same but in the end you will be notified about app uinstalls when enough notifications have failed. updated the response. – Jens Jan 10 '12 at 16:00

2 Answers2

4

I cannot speak for iOS. You cannot get control when your application is uninstalled in Android.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok, understood, but if app is running in background, and I'm going to uninstall it, would be onDestroy() method fired? – devdRew Jan 10 '12 at 12:54
  • @devdRew: I would not count on it. Moreover, even if it does, you would be unable to distinguish between an uninstall and any other scenario in which your `onDestroy()` would be called. – CommonsWare Jan 10 '12 at 12:56
  • Pretty much the only way is to register a repeating "ping" to a server under your control - but this has a tendency to register a lot of false un-installs when people turn off mobile data / go abroad or what have you. – Jens Jan 10 '12 at 13:00
2

That depends on which push service you are using. Afaik, if you are using C2DM, the act of uninstalling the application will automatically unregister it from C2DM.

Edit:

Oh, and about iOS - afaik it does not directly track uninstalled apps, it does however come with a failed notification feedback service that after a sequence of failed notifications (reported by the device to the push network) will notify you - allowing you to clean up after an uninstalled app.

Jens
  • 16,853
  • 4
  • 55
  • 52
  • You're right, we're using C2DM. Thanks, got it. One question about C2DM - does it delivers push notification if application is closed? (not running in background)? – devdRew Jan 10 '12 at 12:55
  • @devdRew: Yes. C2DM will invoke your registered `BroadcastReceiver` even if no component of your app is presently running. – CommonsWare Jan 10 '12 at 13:01
  • 1
    Yes, it will send the push notification as a broadcast Intent (action=com.google.android.c2dm.intent.RECEIVE), so you do not need to be running at all times. – Jens Jan 10 '12 at 13:02