CoreMotion updates in background state

前端 未结 5 1872
迷失自我
迷失自我 2020-12-02 06:57

With the M7 chip in the latest iOS devices one can get programmatically notified as the user goes from stationary to running, walking, etc using CMMotionActivityManager. Sta

5条回答
  •  独厮守ぢ
    2020-12-02 07:18

    What I noticed when you turn off GPS, app will not execute any code in background for iOS 7, app looks like in inactive state. So better while moving to background use startMonitoringSignificantLocationChanges and also get updates from your location manager. Means simultenoulsy use both service startUpdatingLocation on user state change and startMonitoringSignificantLocationChanges in Background.

    So when user Turn on GPS, while you used startMonitoringSignificantLocationChanges your app will receive

    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
    

    Better check here in background itself what wrong with CoreMotion Framework. And try to restart it. Because wihtout M7 chip device I am able to read Accelerometer reading in such case.

提交回复
热议问题