Search code examples
androidamazon-mobile-analytics

AWS Mobile analytics / Sending events when app going to the background


I have an android app and I would like to make sure that when a user leave the application, all the events the user triggered will be submitted.

In AWS mobile analytics the recommendation is to call submit events on all activities onPause method. But given sdk limitation that events are submitted once per minute max I could still lose events. For example if a user exit an activity and then move the app to the background. The exit activity will trigger submit events and the move to the background and if they were less than 1 minute a part the second submit will not submit the events and if the user won't open the app ever again, they will never be submitted.

How can I make sure that all the events are submitted? is there a force submit events?

The solution I found so far - Add a service to the application. When the app goes to the background (a bit tricky but seems possible with https://stackoverflow.com/a/4414191) it will trigger the service. The service will then wait 2 minutes and then trigger submitEvents. This solution is working but seems a bit of an overhead and I would expect the sdk will have some solution for this case.


Solution

  • Currently there is no way to force an event submission within that minute window. However, AWS Mobile Analyitcs is integrated with Amazon Pinpoint, and its SDK does not have this limitation. Please look into moving to the Pinpoint SDK - http://docs.aws.amazon.com/pinpoint/latest/developerguide/mobile-sdk.html