The Pedometer control does not yet work with the ios version of App Inventor


This simple pedometer works on my Android 12. Try the aia on ios and see what happens? It should work (sorry, I do not have ios to test).

See the Pedometer documentation for an explanation of the Save/Reset buttons.

PedometerExample.aia (2.7 KB)

Does the example pedometer work on your ios ? Remember, ios App Inventor currently cannot build the app for installation. Once you run the app you possibly have to stay in range of your WIFI connection for the example to work. (Difficult if you walk around to test :cry: ) Let us know what happens please.

I tried it now. I can see the UI, but the text of label1 doesn't change when I click start and walk around. Anyway, this is not what worries me. I would like to be able to see the UI of the "Exercise Mate" app on iOS, even after removing everything that bothers it. I removed all extensions, and the pedometer sensor too. But, when I load the project in AI Companion, the iphone screen starts flashing and App Inventor shows the "constraint with anchors and because they have no common ancestor" error until I close the AI Companion app.

The full error is "error: Unable to activate constraint with anchors and because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.."

Your experience suggests that the Pedometer control does not yet work with the ios version of App Inventor.

You have to wait until MIT fixes this apparent bug.

you have issues with is in regards to the Exercise Mate App Showcase. Not the simple Pedometer example

The error you get with Exercise Mate implies something in the author's GUI is also incompatible with with ios AI. What? You have to modify the app and see if you can gete it running without the extensions.

Simply, you cannot use the Exercise Mate example with ios and your students.

This is what I tried. But the error "Unable to activate constraint with anchors and because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.." shows up after I removed all extensions and the pedometer too.

This discussion indicates part of your issue may be the Layouts/Arrangements

What is weird (at least to me) is that the app works fine in Android

When I open the app in my iphone 13 and walk around, the two labels keep saying 0. Instead, when I load the app in my (very old) Android phone, the two labels change as soon as I move around.

I merged your topics. Please don't double post.

App Inventor for ios does not presently work with the Pedometer. There is nothing you can do until MIT can provide a solution. What controls work on Android devices does not necessarily work correctly with ios as you discovered.

This is not weird, it is because ios App Inventor still has LOTS of bugs. Realistically, App Inventor for ios is probably never going to work with all the tools available for Android users. This is a fact of life because the two operating systems are different and each has different requirements.

Be happy that the Pedometer works with Android. :slight_smile: Some day :astonished: it will work with ios. When? Next month or next year but not now.

Sorry, I didn't mean double posting. I forgot to add a link to a minimal non working project, MIT App Inventor Gallery

There are two things to untangle here. The issue related to the constraint activation is a known issue in the layout engine that we are working to resolve. It has to do with the use of Fill Parent or percentage sizing of invisible components. You can either switch to absolute sizing of the components, or not make them invisible at the start of the app. Extensions are all non-visible (they aren't part of the view hierarchy) and also are not supported on iOS.

For the pedometer counting issue, I'm not sure what's going on here as the code is implemented and did work at the time it was merged. I'll build a small test app and see if I can understand the root cause. Which version of iOS are you using?

Edit: So I created a very simple app and it appears to work, although it is extremely particular about what it is counting as a step. Internally, we're using the Apple CoreMotion library to manage the step detection and we may need to adjust its sensitivity to give more reasonable step counts.


Do you think using screens instead of visible/invisible layouts would work?

Would you share it so I can test it?

Here it is.

PedometerTest.aia (1.9 KB)

As I mentioned, I had to make very exaggerated movements for it to work, so my guess is there is an issue somewhere in the calculation of how strong a signal a step should be.

So, it this supposed to work? I tried making very large steps, but the content of Label1 doesn't change at all for me.

I'm not saying it "worked" per se, but more that as I walked up stairs, etc. it seemed to register steps on my iPhone X running iOS 15.6.1 and companion version 2.64.

I believe that the behavior is still wrong because I could take many steps before it even registered a single step in the Pedometer.

My working theory is that the original Android code is specified in terms of m/s^2 but the iOS API actually returns units in terms of g. Mathematically, I think the algorithms are equivalent but it's possible that one or more of the computations isn't accounting for g = 9.81 m/s^2, which might explain why the algorithm is so restrictive on the iOS side...

Edit: For clarity, I generated 6 steps total walking around my house.

Ok. It registered 2 steps when I went upstairs (18 real steps, about 2.7m as total vertical distance). It didn't register any step instead when I went back downstairs.

Yep, that seems to match my experience. I think we may need to adjust on iOS for the fact that the motion APIs report in g's rather than m/s^2...