Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

StepCounter unavailable on iOS

Discussion in 'Input System' started by Schroedingers-Cat, Jul 24, 2020.

  1. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
    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: https://developer.apple.com/documentation/coremotion/cmpedometer

    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?
     
  2. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
    Update: Did a downgrade with Unity v2019.4.5 and the iOS minimal target version at 10 - no StepCounter found.
     
  3. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
  4. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
    Any words from the devs about this?
     
  5. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
  6. renelie_s

    renelie_s

    Joined:
    Feb 29, 2020
    Posts:
    7
    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: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Sensors.html
    Apparently, months after the original asker posted this question, iOS StepCounter is still unsupported. :(
     
  7. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    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.
     
  8. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    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.
     
  9. Schroedingers-Cat

    Schroedingers-Cat

    Joined:
    Sep 17, 2019
    Posts:
    7
    @Rene-Damm thanks for looking into this. Any update from the mobile team?
     
  10. renelie_s

    renelie_s

    Joined:
    Feb 29, 2020
    Posts:
    7
    Thanks, @Rene-Damm . Looking forward to the update from the mobile team. :)
     
  11. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
    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.
     
  12. renelie_s

    renelie_s

    Joined:
    Feb 29, 2020
    Posts:
    7
    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?
     
  13. renelie_s

    renelie_s

    Joined:
    Feb 29, 2020
    Posts:
    7
  14. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
    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.
     
  15. renelie_s

    renelie_s

    Joined:
    Feb 29, 2020
    Posts:
    7
    So... this isn't possible either way for now. :(
    Okay, thanks for the response, @Tomas1856
     
  16. Alexis-Dev

    Alexis-Dev

    Joined:
    Apr 16, 2019
    Posts:
    121
    Hello,

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

    Best,
    Alexis
     
  17. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,682
  18. Gusts92

    Gusts92

    Joined:
    Oct 13, 2015
    Posts:
    16
    Last edited: Jun 8, 2021
    sakamoto-kun and Tomas1856 like this.