StepCounter unavailable on iOS

I’m using UnityEngine.InputSystem.StepCounter.current to get access to the pedometer available on iOS and Android. However, StepCounter.current always evaluates to null on iOS while it’s working fine on Android. I also printed out all available sensors on iOS and Android via InputSystem.devices and while StepCounter is available on Android, it isn’t on iOS.

This is happening on an iPhone SE (2020) running iOS 13.6 with Unity 2020.1 and the InputSystem package v1.0.0 with the iOS minimal target version at 11. The Android phone is a Oneplus 5 running LineageOS 16.

According to Apple’s CoreMotion API, a pedometer should be available on iOS 8 and higher: CMPedometer | Apple Developer Documentation

Notice the deprecated CMStepCounter class at the bottom of that page? I wonder if Unity’s new InputSystem uses that deprecated class exclusively, which is only available when targeting iOS 7-8 according to the docs. Unity 2020 can only target at least iOS 11. I wonder if that is the problem and the devs didn’t noticed the iOS limitation/deprecation yet since it worked with previous versions of Unity.

I also added the NSMotionUsageDescription key to the Info.plist, but that didn’t help.

How can I use the InputSystem to access the StepCounter on iOS?

Update: Did a downgrade with Unity v2019.4.5 and the iOS minimal target version at 10 - no StepCounter found.

Update: It doesn’t look like it has been implemented on iOS at all: InputSystem/Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/iOSSupport.cs at develop · Unity-Technologies/InputSystem · GitHub

Any words from the devs about this?

@Rene-Damm ?

Any updates on this? I am on the same case. I would like to use StepCounter on iOS too. Added the NSMotionUsageDescription key to the Info.plist file but it didn’t work.

EDIT: I came across this support page: Sensor support | Input System | 1.0.2
Apparently, months after the original asker posted this question, iOS StepCounter is still unsupported. :frowning:

I’m sorry it’s taking so long to get 1.1 out (which includes the fix for this problem). Current plan is to have it out next week. ////EDIT: wrong fix. Me confused.

Darn, I’m sorry… really not my day. Was confusing the issues. Missing step counter was a separate problem. Let me check with the mobile team on the status of this and get back to you.

@Rene-Damm thanks for looking into this. Any update from the mobile team?

Thanks, @Rene-Damm . Looking forward to the update from the mobile team. :slight_smile:

Hi,

there’s a plan to add support for this sensor in 2021.1, but the task doesn’t have high priority, thus it might miss this deadline.

Alternatively, the input system is flexible enough to allow this sensor to be hooked purely from Unity project, without the need to wait for update. If you’re up for a challenge, I can try to see if I can make an example on how to achieve that.

Oooh! I’d like to know how this can be done. And if so, will it be possible to make this sensor:
[1] work on both iOS and Android, and
[2] still work even then the game/app is not on foreground?

@Tomas1856 @Rene-Damm hello?

On Android there’s already working StepCounter sensor. So only iOS implementation is missing

I can’t answer your [2] second question, at this moment, I don’t know.

So… this isn’t possible either way for now. :frowning:
Okay, thanks for the response, @Tomas1856

Hello,

Any news about this features on iOS?
Or a roadmap for future InputSystem version?

Best,
Alexis

Can’t say when it will be available in production, but here’s a PR Add Step Counter sensor for iOS by todi1856 · Pull Request #1253 · Unity-Technologies/InputSystem · GitHub which provides Step Counter implementation for iOS. If you’re brave, you can take that code and put it locally in your project

Has it been implemented on iOS? Been wanting to try a game idea, but I’d really like to know if it’s working already…

EDIT: Seems like it has, in the changelog over here: Changelog | Input System | 1.1.1

2 Likes