Hi, In an app I'm working on I'm using Region monitoring and couchbase. When I enter the region, I need to save some information to the database and that info needs to be synced to the server ( I have a continuous push replication running) while running the app in the background. I'm setting suspended to NO to tell couchbase to perform the saving and syncing in the background.
I have an important constraint: When the region is detected I have around 10 secs to perform that, otherwise I can request more time with beginBackgroundTaskWithExpirationHandler: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler:> as mentioned in Apple documentation. "In iOS, regions associated with your app are tracked at all times, including when the app isn’t running. If a region boundary is crossed while an app isn’t running, that app is relaunched into the background to handle the event. Similarly, if the app is suspended when the event occurs, it’s woken up and given a short amount of time (around 10 seconds) to handle the event. When necessary, an app can request more background execution time using the beginBackgroundTaskWithExpirationHandler: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler:> method of the UIApplication <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/cl/UIApplication> class." In 3G conditions I found that the 10 secs are often not enough to perform the saving and sync to the remote server, so I need to use some extra time by using beginBackgroundTaskWithExpirationHandler: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler:>. The problem I'm having is that the synchronization dies anyway after the 10 secs even if I use beginBackgroundTaskWithExpirationHandler: <https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/beginBackgroundTaskWithExpirationHandler:>. My hint is that the syncing is probably executing in a different thread and iOS kills it anyway after the 10 secs not taking into account the backgroundtask. Any ideas? Thanks, Martin PS: Thanks for such a great work with couchbase. Below are links to two apps already in the store and google play that I did using couchbase lite. https://itunes.apple.com/en/app/puntatech/id955333100?mt=8 https://play.google.com/store/apps/details?id=com.nearup.puntatech.android https://itunes.apple.com/us/app/mvdvalley/id932392599?mt=8 https://play.google.com/store/apps/details?id=com.nearup.android -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/045fc314-6d6e-4d72-a267-f54e748a0eca%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
