StepCounter doesn't work on iOS when app is turned off

I’m working on the game where I need to count steps for some gameplay features. I’m using InputSystem 1.3.0 and Unity 2020.3.37f1.

I need steps to be counted not only when application is running, but also when it is completely turned off. I’ve managed to do that successfully for android, but I have an issue with iOS. Steps counting for iphone works fine only when application is turned on (it doesn’t matter is it in focus or not). But if I rerun my game, steps counting starts from zero.

I use the following code for iOS:

private void Start()
{
    if (StepCounter.current != null)
    {
            InputSystem.EnableDevice(StepCounter.current);
    }
}

private void Update()
{
        if (StepCounter.current != null)
        {
            _stepsLabel.text = $"Steps: {StepCounter.current.stepCounter.ReadValue()}";
        }
        else
        {
            _stepsLabel.text = $"Steps: NaN";
        }
}

iOSStepCounter.IsAvailable() returns true and iOSStepCounter.AuthorizationStatus returns Authorized.

Also I didn’t forget to enable “Motion usage” option in project settings.

I’m looking forward for any help with this question, thank you!

How did you manage to get it to accumulate steps on Android while the application is off?!

It works out of the box for me. On application start built in steps counter returns total amount of steps made starting from the last device reboot till now.

Of course before using steps counter you need to receive native permission from android (as it is mentioned in docs). And keep in mind, that permissions are different for Android 10+ devices, and for older phones. For newer devices you should request

android.permission.ACTIVITY_RECOGNITION

and for older

com.google.android.gms.permission.ACTIVITY_RECOGNITION

You’re right. I’ve encountered this exact same problem now. iOS resets to 0 on every app restart but Android doesn’t… No idea how to use this stepcounter functionality if it behaves so differently on both platforms.