I'm using the Cordova Gimbal plugin to monitor bluetooth beacons in the background. iOS wakes up the app while in the background to send it bluetooth beacon sighting events; the Gimbal SDK processes these and calls a objc handler function in the plugin. I've removed any code that fires events on the window object in an attempt to prevent any javascript from running while in the 10-second execution window.
However, javascript executes anyway on these background events: my app uses Angular, and expensive $digest
cycles continue in the background. $interval
(wrapper for setInterval()
) works too. It seems that while the app is running in the 10-second window, it just keeps on running the javascript engine as if it were in the foreground. This is significantly affecting battery usage for the app. How can I get the cordova event loop to just stop executing when it's done handling the beacon sighting?
versions: cordova 6.5.0 cordova-ios 4.3.1
I discovered that the javascript engine doesn't run opportunistically like this if we switch to using WKWebView. So, adding this plugin (and fixing the fallout from the switch) fixed the issue.