rng13
rng13

Reputation: 111

pedometer is not working in background mode in ios 13 only

I have an app that just counting steps in Active State and Background Mode with CoreMotion CMPedometer.

It works fine on ios 12.4.1

ios 13: steps counting doesn't work in Background Mode, but work in Active State.

I haven't any errors and in Active State I get "steps, that I went in background".

I have permission NSLocationWhenInUseUsageDescription

In fact, I do not receive a notification (print in console) that I am moving.

Please help.

Upvotes: 3

Views: 891

Answers (1)

Guven
Guven

Reputation: 2310

I have looked into this a little bit and it turns out that the background processing logic has been updated on iOS 13. I see that my steps tracking (CMPedometer) task gets almost immediately killed when the app goes into the background.

You are most likely using application(_:performFetchWithCompletionHandler:) to track user steps and motion in the background. This is now deprecated on iOS 13 SDK and you will need to use BGAppRefreshTask to achieve the same functionality.

More details are in the Apple Documentation here.

Upvotes: 1

Related Questions