background: I’m working on an app that saves a photo with additional information about it. The data needs to be pushed up to the cloud. I also need offline support, so I have a local sqlite database to hold the info.
My workflow is:
-
Save all data locally.
-
Check for internet. If internet proceed to step 3, otherwise resume other tasks
-
Check if local record has referenceId from sever. If not proceed to step 4, otherwise resume other tasks
-
Upload data to server (create a db record)
-
Upload photo (file)
-
Link photo to data
-
Save reference to local sqlite.
-
On applicationResume or applicationOpen events, I jump to step 2.
My problem happens with network access drops or an application suspend (http://docs.coronalabs.com/api/event/system/type.html). The gotchas for all the network request and upload (http://docs.coronalabs.com/api/library/network/request.html#gotchas) indicate no callbacks are sent.
The majority of my issues occur during photo upload. If uploading the photo takes a long time, odds are a suspend event will occur and either stop the upload/request or block the callback. I try to upload the file again during applicationResume/applicationOpen event resulting in multiple uploads.
Usually, inactivity is the reason why the upload fails. Does anyone know how to prevent this? Is there a way to reset the inactivity timer?
I really want to avoid a message on the screen saying “please tap so the device does not go to sleep and cancel your upload”