Background Syncing in iOS
chris-guidry opened this issue · 2 comments
Within this repo I have read all of the posts I could find about background syncing in iOS and reviewed the ble-background example, but that example only waits three seconds before starting the scan, so I am guessing the test app is only suspended, and not fully moved to a background state. Also, it's only running once instead of running repeatedly.
In my app I am using setInterval
to check every minute if there is a device that is due to be synced and in range by running ble.scan
. This process runs great while in the foreground, but when the app moves to the background the function specified in the setInterval command is no longer executed, which is why I think the ble-background example is not quite a full background syncing test.
I installed the plugin cordova-custom-config, added the settings for Background Scanning and Notifications on iOS, and verified those settings are being added to the Info.plist file. In the ble.scan command I am including a service that is specific to my device: ble.scan([config.bluetooth.custom.service], seconds, success, failure);.
I also installed the plugin cordova-plugin-background-fetch, which allows a javascript function to be executed every 15 minutes for 30 seconds. My function (which runs fine in the foreground) hangs when ble.scan is called and doesn't return anything. It seems that iOS is not allowing that command in this instance.
How are folks getting the scan to run at regular intervals in the background or otherwise connecting to peripheral devices in the background?
I just noticed the ble-background example uses ble.startScan and I guess it runs indefinitely? Have folks built an app that way and had it approved by Apple?
Closing for now. I am assuming the function ble.startScan needs to be used.