I need to register accelerometer data from CoreMotion even when the app is in background. Reading other questions on this network I've found out that I have to:
- Use CoreLocation to get location updates and requesting the authorization to run always (locationManager.requestAlwaysAuthorization())
- Enable background modes in capabilities and check "location updates"
- Set the NSLocationAlwaysUsageDescription key in the Info.plist file
- Call locationManager.startMonitoringSignificantLocationChanges() when the app enters in background
But I still can't manager to get accelerometer data updates in background mode. I am sure of this because I save the data in an array (which lately stored in a database), and I tag every accelerometer data object with the timestamp. If I put the app in background by simply pushing the home screen and wait some seconds before going in foreground again, I can see that there is a time gap in the updates (e.g. skipping from 2.06 to 9.66). What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire