Looking for a way to measure distance for workout app


I am working on a workout app and I am looking for a way to allow users to set a distance (in km) for their activity (run/walk/…) and give a feedback during the activity.
What is the best way to achieve that?


Your question is rather vague, but I would start by looking at the Pedometer plugin.


Why vague?
Think of the following usage:
James wants to go out and run 5 km. He should be able to set distance (5 km) press start and off he goes.
James would like to know when he passes half of the way (after 2.5 km some notification should be sent - probably some audio effect).

This is the second feature of my app.
The first was set time interval for the workout. For example, James can set a walk interval of 10 minutes or a run interval of 3 minutes. I wrote a basic timer for this feature but for the distance feature I need some help :slight_smile:

About the plugin you suggest. How do I install it? I don’t see its documentation on ionic-native doc page.

Thank you for your help.


Looks like it’s there to me.


I searched in the wrong tab :blush:
Thank you, I will try it.


Distance estimation indicates the ability to use step information to supply the approximate distance travelled by the user. This capability is not supported on all devices, even with iOS 8. Only works on iOS.

I’m working with Android :frowning:

      .then((available: boolean) => console.log(available))
      .catch((error: any) => console.log(error));

07-07 01:14:09.603 D/SystemWebChromeClient(22501): file:///android_asset/www/cordova.js: Line 312 : Error in Error callbackId: Pedometer1206703277 : [object Object]
07-07 01:14:09.603 I/chromium(22501): [INFO:CONSOLE(312)] "Error in Error callbackId: Pedometer1206703277 : [object Object]", source: file:///android_asset/www/cordova.js (312)
07-07 01:14:09.603 D/SystemWebChromeClient(22501): file:///android_asset/www/build/main.js: Line 56034 : false
07-07 01:14:09.603 I/chromium(22501): [INFO:CONSOLE(56034)] "false", source: file:///android_asset/www/build/main.js (56034)

Is there something similar for Android?


Plugin docs say live pedometer data works on Android; can you make something from that?


What am I missing?

try {
  console.log("Starting Pedometer");
  .subscribe((data: IPedometerData) => {
} catch (error) {
  console.error("Something went wrong with Pedometer: ", error);
07-07 01:29:27.949 D/SystemWebChromeClient(24493): file:///android_asset/www/build/main.js: Line 56034 : Starting Pedometer
07-07 01:29:27.949 I/chromium(24493): [INFO:CONSOLE(56034)] "Starting Pedometer", source: file:///android_asset/www/build/main.js (56034)
07-07 01:29:28.069 D/SystemWebChromeClient(24493): file:///android_asset/www/cordova.js: Line 312 : Error in Error callbackId: Pedometer431046343 : [object Object]
07-07 01:29:28.069 I/chromium(24493): [INFO:CONSOLE(312)] "Error in Error callbackId: Pedometer431046343 : [object Object]", source: file:///android_asset/www/cordova.js (312)
07-07 01:29:28.089 D/SystemWebChromeClient(24493): file:///android_asset/www/build/main.js: Line 1362 : ERROR
07-07 01:29:28.089 I/chromium(24493): [INFO:CONSOLE(1362)] "ERROR", source: file:///android_asset/www/build/main.js (1362)

What does it mean error in error callback id?


I don’t know; I haven’t actually used this plugin. You may also want to take a look at stepcounter instead.


OK I will check it out.
Tell me please, don’t you think some gps plugin would be better than a step-counter based plugin?


I’m not sure if it’s what you’re after but you could try the geolocation plugin. Just take their start location and calculate the distance travelled between their current location.