├── src ├── .npmignore ├── references.d.ts ├── index.d.ts ├── platforms │ └── ios │ │ └── Info.plist ├── package.json ├── pedometer.common.ts ├── pedometer.android.ts ├── pedometer.ios.ts └── package-lock.json ├── media ├── demo.png └── tie-shoes.jpg ├── demo ├── app │ ├── app.ts │ ├── App_Resources │ │ ├── iOS │ │ │ ├── Assets.xcassets │ │ │ │ ├── Contents.json │ │ │ │ ├── AppIcon.appiconset │ │ │ │ │ ├── icon-29.png │ │ │ │ │ ├── icon-40.png │ │ │ │ │ ├── icon-50.png │ │ │ │ │ ├── icon-57.png │ │ │ │ │ ├── icon-72.png │ │ │ │ │ ├── icon-76.png │ │ │ │ │ ├── icon-29@2x.png │ │ │ │ │ ├── icon-29@3x.png │ │ │ │ │ ├── icon-40@2x.png │ │ │ │ │ ├── icon-40@3x.png │ │ │ │ │ ├── icon-50@2x.png │ │ │ │ │ ├── icon-57@2x.png │ │ │ │ │ ├── icon-60@2x.png │ │ │ │ │ ├── icon-60@3x.png │ │ │ │ │ ├── icon-72@2x.png │ │ │ │ │ ├── icon-76@2x.png │ │ │ │ │ ├── icon-83.5@2x.png │ │ │ │ │ └── Contents.json │ │ │ │ ├── LaunchImage.launchimage │ │ │ │ │ ├── Default.png │ │ │ │ │ ├── Default@2x.png │ │ │ │ │ ├── Default-568h@2x.png │ │ │ │ │ ├── Default-667h@2x.png │ │ │ │ │ ├── Default-736h@3x.png │ │ │ │ │ ├── Default-Portrait.png │ │ │ │ │ ├── Default-Landscape.png │ │ │ │ │ ├── Default-Portrait@2x.png │ │ │ │ │ ├── Default-Landscape@2x.png │ │ │ │ │ ├── Default-Landscape@3x.png │ │ │ │ │ └── Contents.json │ │ │ │ ├── LaunchScreen.Center.imageset │ │ │ │ │ ├── LaunchScreen-Center.png │ │ │ │ │ ├── LaunchScreen-Center@2x.png │ │ │ │ │ └── Contents.json │ │ │ │ └── LaunchScreen.AspectFill.imageset │ │ │ │ │ ├── LaunchScreen-AspectFill.png │ │ │ │ │ ├── LaunchScreen-AspectFill@2x.png │ │ │ │ │ └── Contents.json │ │ │ ├── build.xcconfig │ │ │ ├── Info.plist │ │ │ └── LaunchScreen.storyboard │ │ └── Android │ │ │ ├── values-v21 │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ │ ├── drawable-hdpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── drawable-ldpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── drawable-mdpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── drawable-xhdpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── drawable-xxhdpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── drawable-xxxhdpi │ │ │ ├── icon.png │ │ │ ├── logo.png │ │ │ └── background.png │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ │ ├── drawable-nodpi │ │ │ └── splash_screen.xml │ │ │ ├── app.gradle │ │ │ └── AndroidManifest.xml │ ├── main-page.ts │ ├── app.css │ ├── package.json │ ├── main-page.xml │ └── main-view-model.ts ├── references.d.ts ├── tsconfig.json ├── package.json ├── .vscode │ └── launch.json └── package-lock.json ├── publish ├── publish.sh ├── package.json ├── pack.sh └── package-lock.json ├── .gitignore ├── tsconfig.json ├── LICENSE └── README.md /src/.npmignore: -------------------------------------------------------------------------------- 1 | *.map 2 | tsconfig.json 3 | *.ts 4 | !*.d.ts 5 | -------------------------------------------------------------------------------- /media/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/media/demo.png -------------------------------------------------------------------------------- /media/tie-shoes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/media/tie-shoes.jpg -------------------------------------------------------------------------------- /demo/app/app.ts: -------------------------------------------------------------------------------- 1 | import * as application from "application"; 2 | application.start({ moduleName: "main-page" }); 3 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/values-v21/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3d5afe 4 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-hdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-hdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-ldpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-ldpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxhdpi/logo.png -------------------------------------------------------------------------------- /demo/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-hdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-ldpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-ldpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-mdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-mdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-xxxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/Android/drawable-xxxhdpi/background.png -------------------------------------------------------------------------------- /publish/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACK_DIR=package; 4 | 5 | publish() { 6 | cd $PACK_DIR 7 | echo 'Publishing to npm...' 8 | npm publish *.tgz 9 | } 10 | 11 | ./pack.sh && publish -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png -------------------------------------------------------------------------------- /publish/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "description": "Publish helper", 5 | "devDependencies": { 6 | "ncp": "^2.0.0", 7 | "rimraf": "^2.5.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png -------------------------------------------------------------------------------- /src/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EddyVerbruggen/nativescript-pedometer/HEAD/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * iOS and Android apis should match. 3 | * It doesn't matter if you export `.ios` or `.android`, either one but only one. 4 | */ 5 | export * from "./pedometer.ios"; 6 | 7 | // Export any shared classes, constants, etc. 8 | export * from "./pedometer.common"; -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F5F5F5 4 | #757575 5 | #33B5E5 6 | #272734 7 | -------------------------------------------------------------------------------- /src/platforms/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSMotionUsageDescription 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/build.xcconfig: -------------------------------------------------------------------------------- 1 | // You can add custom settings here 2 | // for example you can uncomment the following line to force distribution code signing 3 | // CODE_SIGN_IDENTITY = iPhone Distribution 4 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 5 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .idea/ 3 | .DS_Store 4 | *.js 5 | *.js.map 6 | *.log.* 7 | lib 8 | src/*.d.ts 9 | src/platforms/android/*.aar 10 | !src/index.d.ts 11 | !src/references.d.ts 12 | demo/*.d.ts 13 | demo/app/*.d.ts 14 | !demo/references.d.ts 15 | demo/platforms 16 | demo/.nsbuildinfo 17 | node_modules 18 | publish/package 19 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/drawable-nodpi/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/app/main-page.ts: -------------------------------------------------------------------------------- 1 | import * as observable from "data/observable"; 2 | import * as pages from "ui/page"; 3 | import {HelloWorldModel} from "./main-view-model"; 4 | 5 | // Event handler for Page "loaded" event attached in main-page.xml 6 | export function pageLoaded(args: observable.EventData) { 7 | // Get the event sender 8 | let page = args.object; 9 | page.bindingContext = new HelloWorldModel(); 10 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/app.gradle: -------------------------------------------------------------------------------- 1 | // Add your native dependencies here: 2 | 3 | // Uncomment to add recyclerview-v7 dependency 4 | //dependencies { 5 | // compile 'com.android.support:recyclerview-v7:+' 6 | //} 7 | 8 | android { 9 | defaultConfig { 10 | generatedDensities = [] 11 | applicationId = "org.nativescript.starter" 12 | } 13 | aaptOptions { 14 | additionalParameters "--no-version-vectors" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-Center.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-Center@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-AspectFill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-AspectFill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "experimentalDecorators": true, 6 | "noEmitHelpers": true, 7 | "lib": [ 8 | "es6", 9 | "dom" 10 | ], 11 | "baseUrl": ".", 12 | "paths": { 13 | "~/*": [ 14 | "app/*" 15 | ], 16 | "*": [ 17 | "./node_modules/tns-core-modules/*", 18 | "./node_modules/*" 19 | ] 20 | } 21 | }, 22 | "exclude": [ 23 | "node_modules", 24 | "platforms" 25 | ] 26 | } -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "nativescript": { 3 | "id": "org.nativescript.demo", 4 | "tns-android": { 5 | "version": "4.2.0" 6 | }, 7 | "tns-ios": { 8 | "version": "4.2.0" 9 | } 10 | }, 11 | "dependencies": { 12 | "nativescript-pedometer": "file:../src", 13 | "tns-core-modules": "~4.2.0" 14 | }, 15 | "devDependencies": { 16 | "babel-traverse": "6.12.0", 17 | "babel-types": "6.11.1", 18 | "babylon": "6.8.4", 19 | "filewalker": "0.1.2", 20 | "lazy": "1.0.11", 21 | "nativescript-dev-typescript": "~0.7.4", 22 | "tns-platform-declarations": "~4.2.0", 23 | "typescript": "~2.7.2" 24 | } 25 | } -------------------------------------------------------------------------------- /demo/app/app.css: -------------------------------------------------------------------------------- 1 | page { 2 | background-color: #F4F4F4; 3 | } 4 | 5 | .tab-content { 6 | color: #808080; 7 | padding: 20; 8 | } 9 | 10 | Label { 11 | font-size: 15; 12 | color: #555; 13 | padding: 6 0; 14 | } 15 | 16 | .title { 17 | color: #222; 18 | font-size: 18; 19 | padding-top: 18; 20 | } 21 | 22 | .error { 23 | color: #FF0000 24 | } 25 | 26 | .key { 27 | color: #555 28 | } 29 | 30 | .value { 31 | color: #888 32 | } 33 | 34 | button { 35 | background-color: #3598db; 36 | padding: 3 0; 37 | margin: 3 10; 38 | font-size: 12; 39 | border-radius: 4; 40 | height: 30; 41 | } 42 | 43 | .button { 44 | color: #FFFFFF; 45 | } 46 | 47 | .button-start { 48 | background-color: #00BB00; 49 | } 50 | 51 | .button-stop { 52 | background-color: #DD0000; 53 | } 54 | 55 | .button-availability { 56 | margin: 3; 57 | font-size: 12; 58 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "removeComments": true, 7 | "noLib": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "skipLibCheck": true, 11 | "lib": [ 12 | "es2016" 13 | ], 14 | "sourceMap": true, 15 | "pretty": true, 16 | "allowUnreachableCode": false, 17 | "allowUnusedLabels": false, 18 | "noEmitHelpers": true, 19 | "noEmitOnError": false, 20 | "noImplicitAny": false, 21 | "noImplicitReturns": true, 22 | "noImplicitUseStrict": false, 23 | "noFallthroughCasesInSwitch": true, 24 | "typeRoots": [ 25 | "./node_modules/@types", 26 | "./node_modules" 27 | ], 28 | "types": [ 29 | ] 30 | }, 31 | "exclude": [ 32 | "demo", 33 | "node_modules" 34 | ], 35 | "compileOnSave": false 36 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 14 | 15 | 16 | 19 | 20 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | nativescript-yourplugin 4 | Copyright (c) 2016, Your Name 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /publish/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE_DIR=../src; 4 | TO_SOURCE_DIR=src; 5 | PACK_DIR=package; 6 | ROOT_DIR=..; 7 | PUBLISH=--publish 8 | 9 | install(){ 10 | npm i 11 | } 12 | 13 | pack() { 14 | 15 | echo 'Clearing /src and /package...' 16 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 17 | node_modules/.bin/rimraf "$PACK_DIR" 18 | 19 | # copy src 20 | echo 'Copying src...' 21 | node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR" 22 | 23 | # copy README & LICENSE to src 24 | echo 'Copying README and LICENSE to /src...' 25 | node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE 26 | node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md 27 | 28 | # compile package and copy files required by npm 29 | echo 'Building /src...' 30 | cd "$TO_SOURCE_DIR" 31 | node_modules/.bin/tsc 32 | cd .. 33 | 34 | echo 'Creating package...' 35 | # create package dir 36 | mkdir "$PACK_DIR" 37 | 38 | # create the package 39 | cd "$PACK_DIR" 40 | npm pack ../"$TO_SOURCE_DIR" 41 | 42 | # delete source directory used to create the package 43 | cd .. 44 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 45 | } 46 | 47 | install && pack -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-pedometer", 3 | "version": "2.1.0", 4 | "description": "NativeScript pedometer plugin. Step counting FTW!", 5 | "main": "pedometer", 6 | "typings": "index.d.ts", 7 | "nativescript": { 8 | "platforms": { 9 | "android": "2.3.0", 10 | "ios": "2.3.0" 11 | } 12 | }, 13 | "scripts": { 14 | "build": "tsc --skipLibCheck", 15 | "demo.ios": "npm run preparedemo && cd ../demo && tns run ios", 16 | "demo.android": "npm run preparedemo && cd ../demo && tns run android", 17 | "preparedemo": "npm run build && cd ../demo && tns plugin remove nativescript-pedometer && tns plugin add ../src && tns install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/EddyVerbruggen/nativescript-pedometer.git" 22 | }, 23 | "keywords": [ 24 | "NativeScript", 25 | "ecosystem:nativescript", 26 | "Android", 27 | "iOS", 28 | "Pedometer", 29 | "Stepcounter", 30 | "Steps", 31 | "Distance", 32 | "Pace", 33 | "Floors" 34 | ], 35 | "author": { 36 | "name": "Your Name", 37 | "email": "youremail@yourdomain.com" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/EddyVerbruggen/nativescript-pedometer/issues" 41 | }, 42 | "license": "MIT", 43 | "homepage": "https://github.com/EddyVerbruggen/nativescript-pedometer", 44 | "readmeFilename": "README.md", 45 | "devDependencies": { 46 | "tns-core-modules": "~4.2.0", 47 | "tns-platform-declarations": "~4.2.0", 48 | "typescript": "~2.7.0", 49 | "prompt": "^1.0.0", 50 | "rimraf": "^2.5.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Pedometer 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | Pedometer 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiresFullScreen 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 21 | 22 | 23 | 31 | 32 | 34 | 35 | 36 | 42 | 43 | 45 | 46 | -------------------------------------------------------------------------------- /demo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Sync on iOS", 6 | "type": "nativescript", 7 | "platform": "ios", 8 | "request": "launch", 9 | "appRoot": "${workspaceRoot}", 10 | "sourceMaps": true, 11 | "diagnosticLogging": false, 12 | "emulator": false, 13 | "rebuild": false, 14 | "syncAllFiles": false 15 | }, 16 | { 17 | "name": "Launch on iOS", 18 | "type": "nativescript", 19 | "platform": "ios", 20 | "request": "launch", 21 | "appRoot": "${workspaceRoot}", 22 | "sourceMaps": true, 23 | "diagnosticLogging": false, 24 | "emulator": false, 25 | "rebuild": true 26 | }, 27 | { 28 | "name": "Attach on iOS", 29 | "type": "nativescript", 30 | "platform": "ios", 31 | "request": "attach", 32 | "appRoot": "${workspaceRoot}", 33 | "sourceMaps": true, 34 | "diagnosticLogging": false, 35 | "emulator": false 36 | }, 37 | { 38 | "name": "Sync on Android", 39 | "type": "nativescript", 40 | "platform": "android", 41 | "request": "launch", 42 | "appRoot": "${workspaceRoot}", 43 | "sourceMaps": true, 44 | "diagnosticLogging": false, 45 | "emulator": false, 46 | "rebuild": false 47 | }, 48 | { 49 | "name": "Launch on Android", 50 | "type": "nativescript", 51 | "platform": "android", 52 | "request": "launch", 53 | "appRoot": "${workspaceRoot}", 54 | "sourceMaps": true, 55 | "diagnosticLogging": false, 56 | "emulator": false, 57 | "rebuild": true 58 | }, 59 | { 60 | "name": "Attach on Android", 61 | "type": "nativescript", 62 | "platform": "android", 63 | "request": "attach", 64 | "appRoot": "${workspaceRoot}", 65 | "sourceMaps": true, 66 | "diagnosticLogging": false, 67 | "emulator": false 68 | } 69 | ] 70 | } -------------------------------------------------------------------------------- /src/pedometer.common.ts: -------------------------------------------------------------------------------- 1 | export interface PedometerUpdate { 2 | /** 3 | * This is when recording of the currently returned data was started. 4 | */ 5 | startDate: Date; 6 | /** 7 | * This is when recording of the currently returned data was ended (usually: now). 8 | */ 9 | endDate: Date; 10 | /** 11 | * The number of steps taken between startDate and endDate. 12 | */ 13 | steps: number; 14 | /** 15 | * The distance covered in meters between startDate and endDate. 16 | */ 17 | distance?: number; 18 | /** 19 | * The number of floors ascended between startDate and endDate. 20 | * iOS only. 21 | */ 22 | floorsAscended?: number; 23 | /** 24 | * The number of floors descended between startDate and endDate. 25 | * iOS only. 26 | */ 27 | floorsDescended?: number; 28 | /** 29 | * The current pace in seconds per meter. 30 | * iOS 9+ only. 31 | */ 32 | currentPace?: number; 33 | /** 34 | * The current cadence in steps per second. 35 | * iOS 9+ only. 36 | */ 37 | currentCadence?: number; 38 | /** 39 | * The average pace while active in seconds per meter between startDate and endDate. 40 | * iOS 10+ only. 41 | */ 42 | averageActivePace?: number; 43 | } 44 | 45 | export interface PedometerEventUpdate { 46 | type: string; 47 | date: Date; 48 | } 49 | 50 | export interface PedometerStartUpdatesOptions { 51 | /** 52 | * Since what date/time do you want to receive updates? 53 | * Default: now. 54 | */ 55 | fromDate?: Date; 56 | /** 57 | * Since this method will continuously return data we can't use a Promise, 58 | * so pass in this callback function instread. 59 | */ 60 | onUpdate: (data: PedometerUpdate) => void; 61 | } 62 | 63 | export interface PedometerStartEventUpdatesOptions { 64 | /** 65 | * Since this method will continuously return data we can't use a Promise, 66 | * so pass in this callback function instread. 67 | */ 68 | onUpdate: (data: PedometerEventUpdate) => void; 69 | } 70 | 71 | export interface PedometerQueryOptions { 72 | /** 73 | * Since what date/time do you want to receive all data? 74 | */ 75 | fromDate: Date; 76 | /** 77 | * Until what date/time do you want to receive all data? 78 | * Default: now. 79 | */ 80 | toDate?: Date; 81 | } 82 | 83 | export class Common { 84 | constructor() { 85 | } 86 | } -------------------------------------------------------------------------------- /demo/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tns-template-hello-world-ts", 3 | "main": "app.js", 4 | "version": "1.6.0", 5 | "author": { 6 | "name": "Telerik", 7 | "email": "support@telerik.com" 8 | }, 9 | "description": "Nativescript hello-world-ts project template", 10 | "license": "Apache-2.0", 11 | "keywords": [ 12 | "telerik", 13 | "mobile", 14 | "nativescript", 15 | "{N}", 16 | "tns", 17 | "appbuilder", 18 | "template" 19 | ], 20 | "repository": { 21 | "type": "git", 22 | "url": "git+ssh://git@github.com/NativeScript/template-hello-world-ts.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/NativeScript/template-hello-world-ts/issues" 26 | }, 27 | "homepage": "https://github.com/NativeScript/template-hello-world-ts", 28 | "android": { 29 | "v8Flags": "--expose_gc" 30 | }, 31 | "devDependencies": { 32 | "nativescript-dev-typescript": "^0.3.0" 33 | }, 34 | "_id": "tns-template-hello-world-ts@1.6.0", 35 | "_shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8", 36 | "_resolved": "https://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz", 37 | "_from": "tns-template-hello-world-ts@latest", 38 | "scripts": {}, 39 | "_npmVersion": "2.14.7", 40 | "_nodeVersion": "4.2.2", 41 | "_npmUser": { 42 | "name": "enchev", 43 | "email": "vladimir.enchev@gmail.com" 44 | }, 45 | "dist": { 46 | "shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8", 47 | "tarball": "http://registry.npmjs.org/tns-template-hello-world-ts/-/tns-template-hello-world-ts-1.6.0.tgz" 48 | }, 49 | "maintainers": [ 50 | { 51 | "name": "enchev", 52 | "email": "vladimir.enchev@gmail.com" 53 | }, 54 | { 55 | "name": "erjangavalji", 56 | "email": "erjan.gavalji@gmail.com" 57 | }, 58 | { 59 | "name": "fatme", 60 | "email": "hfatme@gmail.com" 61 | }, 62 | { 63 | "name": "hdeshev", 64 | "email": "hristo@deshev.com" 65 | }, 66 | { 67 | "name": "kerezov", 68 | "email": "d.kerezov@gmail.com" 69 | }, 70 | { 71 | "name": "ligaz", 72 | "email": "stefan.dobrev@gmail.com" 73 | }, 74 | { 75 | "name": "nsndeck", 76 | "email": "nedyalko.nikolov@telerik.com" 77 | }, 78 | { 79 | "name": "rosen-vladimirov", 80 | "email": "rosen.vladimirov.91@gmail.com" 81 | }, 82 | { 83 | "name": "sdobrev", 84 | "email": "stefan.dobrev@gmail.com" 85 | }, 86 | { 87 | "name": "tailsu", 88 | "email": "tailsu@gmail.com" 89 | }, 90 | { 91 | "name": "teobugslayer", 92 | "email": "teobugslayer@gmail.com" 93 | }, 94 | { 95 | "name": "valio.stoychev", 96 | "email": "valio.stoychev@gmail.com" 97 | } 98 | ], 99 | "_npmOperationalInternal": { 100 | "host": "packages-5-east.internal.npmjs.com", 101 | "tmp": "tmp/tns-template-hello-world-ts-1.6.0.tgz_1455717516189_0.6427943941671401" 102 | }, 103 | "directories": {}, 104 | "readme": "ERROR: No README data found!" 105 | } 106 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "icon-29.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "icon-29@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-29@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "icon-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon-40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "icon-57.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "icon-57@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "icon-29.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "icon-29@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "icon-40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "icon-40@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "icon-50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "icon-50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "icon-72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "icon-72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "icon-76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "icon-76@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "icon-83.5@2x.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /publish/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "balanced-match": { 8 | "version": "1.0.0", 9 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 10 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 11 | "dev": true 12 | }, 13 | "brace-expansion": { 14 | "version": "1.1.11", 15 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 16 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 17 | "dev": true, 18 | "requires": { 19 | "balanced-match": "1.0.0", 20 | "concat-map": "0.0.1" 21 | } 22 | }, 23 | "concat-map": { 24 | "version": "0.0.1", 25 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 26 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 27 | "dev": true 28 | }, 29 | "fs.realpath": { 30 | "version": "1.0.0", 31 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 32 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 33 | "dev": true 34 | }, 35 | "glob": { 36 | "version": "7.1.3", 37 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", 38 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", 39 | "dev": true, 40 | "requires": { 41 | "fs.realpath": "1.0.0", 42 | "inflight": "1.0.6", 43 | "inherits": "2.0.3", 44 | "minimatch": "3.0.4", 45 | "once": "1.4.0", 46 | "path-is-absolute": "1.0.1" 47 | } 48 | }, 49 | "inflight": { 50 | "version": "1.0.6", 51 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 52 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 53 | "dev": true, 54 | "requires": { 55 | "once": "1.4.0", 56 | "wrappy": "1.0.2" 57 | } 58 | }, 59 | "inherits": { 60 | "version": "2.0.3", 61 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 62 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 63 | "dev": true 64 | }, 65 | "minimatch": { 66 | "version": "3.0.4", 67 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 68 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 69 | "dev": true, 70 | "requires": { 71 | "brace-expansion": "1.1.11" 72 | } 73 | }, 74 | "ncp": { 75 | "version": "2.0.0", 76 | "resolved": "http://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", 77 | "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", 78 | "dev": true 79 | }, 80 | "once": { 81 | "version": "1.4.0", 82 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 83 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 84 | "dev": true, 85 | "requires": { 86 | "wrappy": "1.0.2" 87 | } 88 | }, 89 | "path-is-absolute": { 90 | "version": "1.0.1", 91 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 92 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 93 | "dev": true 94 | }, 95 | "rimraf": { 96 | "version": "2.6.2", 97 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", 98 | "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", 99 | "dev": true, 100 | "requires": { 101 | "glob": "7.1.3" 102 | } 103 | }, 104 | "wrappy": { 105 | "version": "1.0.2", 106 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 107 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 108 | "dev": true 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default-736h@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "Default-Landscape@3x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "landscape", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "Default-667h@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "Default@2x.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "Default-568h@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "orientation" : "portrait", 49 | "idiom" : "ipad", 50 | "filename" : "Default-Portrait.png", 51 | "extent" : "full-screen", 52 | "minimum-system-version" : "7.0", 53 | "scale" : "1x" 54 | }, 55 | { 56 | "orientation" : "landscape", 57 | "idiom" : "ipad", 58 | "filename" : "Default-Landscape.png", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "orientation" : "portrait", 65 | "idiom" : "ipad", 66 | "filename" : "Default-Portrait@2x.png", 67 | "extent" : "full-screen", 68 | "minimum-system-version" : "7.0", 69 | "scale" : "2x" 70 | }, 71 | { 72 | "orientation" : "landscape", 73 | "idiom" : "ipad", 74 | "filename" : "Default-Landscape@2x.png", 75 | "extent" : "full-screen", 76 | "minimum-system-version" : "7.0", 77 | "scale" : "2x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "filename" : "Default.png", 83 | "extent" : "full-screen", 84 | "scale" : "1x" 85 | }, 86 | { 87 | "orientation" : "portrait", 88 | "idiom" : "iphone", 89 | "filename" : "Default@2x.png", 90 | "extent" : "full-screen", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "iphone", 96 | "filename" : "Default-568h@2x.png", 97 | "extent" : "full-screen", 98 | "subtype" : "retina4", 99 | "scale" : "2x" 100 | }, 101 | { 102 | "orientation" : "portrait", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "portrait", 109 | "idiom" : "ipad", 110 | "filename" : "Default-Portrait.png", 111 | "extent" : "full-screen", 112 | "scale" : "1x" 113 | }, 114 | { 115 | "orientation" : "landscape", 116 | "idiom" : "ipad", 117 | "extent" : "to-status-bar", 118 | "scale" : "1x" 119 | }, 120 | { 121 | "orientation" : "landscape", 122 | "idiom" : "ipad", 123 | "filename" : "Default-Landscape.png", 124 | "extent" : "full-screen", 125 | "scale" : "1x" 126 | }, 127 | { 128 | "orientation" : "portrait", 129 | "idiom" : "ipad", 130 | "extent" : "to-status-bar", 131 | "scale" : "2x" 132 | }, 133 | { 134 | "orientation" : "portrait", 135 | "idiom" : "ipad", 136 | "filename" : "Default-Portrait@2x.png", 137 | "extent" : "full-screen", 138 | "scale" : "2x" 139 | }, 140 | { 141 | "orientation" : "landscape", 142 | "idiom" : "ipad", 143 | "extent" : "to-status-bar", 144 | "scale" : "2x" 145 | }, 146 | { 147 | "orientation" : "landscape", 148 | "idiom" : "ipad", 149 | "filename" : "Default-Landscape@2x.png", 150 | "extent" : "full-screen", 151 | "scale" : "2x" 152 | } 153 | ], 154 | "info" : { 155 | "version" : 1, 156 | "author" : "xcode" 157 | } 158 | } -------------------------------------------------------------------------------- /src/pedometer.android.ts: -------------------------------------------------------------------------------- 1 | import {Common, PedometerStartUpdatesOptions, PedometerStartEventUpdatesOptions, PedometerQueryOptions} from "./pedometer.common"; 2 | import * as utils from "tns-core-modules/utils/utils"; 3 | 4 | enum STATE { 5 | STARTING, 6 | STARTED, 7 | ERROR_FAILED_TO_START, 8 | STOPPED 9 | } 10 | 11 | export class Pedometer extends Common { 12 | 13 | private sensor; 14 | private sensorManager; 15 | private sensorEventListener; 16 | private state: STATE; 17 | private startSteps = 0; 18 | private startTimestamp = 0; 19 | 20 | constructor() { 21 | super(); 22 | this.sensorManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.SENSOR_SERVICE); 23 | } 24 | 25 | public isStepCountingAvailable(): Promise { 26 | return new Promise((resolve, reject) => { 27 | let sensors = this.sensorManager.getSensorList(19); // android.hardware.Sensor.TYPE_STEP_COUNTER); 28 | resolve(sensors.size() > 0); 29 | }); 30 | } 31 | 32 | public isDistanceAvailable(): Promise { 33 | return new Promise((resolve, reject) => { 34 | resolve(false); 35 | }); 36 | } 37 | 38 | public isFloorCountingAvailable(): Promise { 39 | return new Promise((resolve, reject) => { 40 | resolve(false); 41 | }); 42 | } 43 | 44 | public isPaceAvailable(): Promise { 45 | return new Promise((resolve, reject) => { 46 | resolve(false); 47 | }); 48 | } 49 | 50 | public isCadenceAvailable(): Promise { 51 | return new Promise((resolve, reject) => { 52 | resolve(false); 53 | }); 54 | } 55 | 56 | public isEventTrackingAvailable(): Promise { 57 | return new Promise((resolve, reject) => { 58 | resolve(false); 59 | }); 60 | } 61 | 62 | public startUpdates(arg: PedometerStartUpdatesOptions): Promise { 63 | return new Promise((resolve, reject) => { 64 | try { 65 | if (!arg || typeof arg.onUpdate !== "function") { 66 | reject("onUpdate argument is required"); 67 | return; 68 | } 69 | 70 | let sensors = this.sensorManager.getSensorList(19); // android.hardware.Sensor.TYPE_STEP_COUNTER); 71 | if (sensors.size() > 0) { 72 | this.sensor = sensors.get(0); 73 | this.startSteps = 0; 74 | 75 | // unlike iOS, Android doesn't support history when querying the step sensor, so we're grabbing it manually 76 | if (arg.fromDate) { 77 | console.log("Note that unlike iOS, Android doesn't support historic step data. Alternative, use this: https://github.com/EddyVerbruggen/nativescript-health-data/tree/cb852903bbf8fbad7d63b6c1df799a97014746d1#query"); 78 | } 79 | 80 | this.startTimestamp = new Date().getTime(); 81 | 82 | this.sensorEventListener = new android.hardware.SensorEventListener({ 83 | onSensorChanged: sensorEvent => { 84 | if (sensorEvent.sensor.getType() === 19) { 85 | if (this.state === STATE.STOPPED) { 86 | return; 87 | } 88 | this.state = STATE.STARTED; 89 | 90 | let steps = sensorEvent.values[0]; 91 | 92 | if (this.startSteps === 0) { 93 | this.startSteps = steps; 94 | } 95 | 96 | steps = steps - this.startSteps; 97 | 98 | arg.onUpdate({ 99 | startDate: new Date(this.startTimestamp), 100 | endDate: new Date(), 101 | steps: steps 102 | }); 103 | } 104 | }, 105 | onAccuracyChanged: (sensor, accuracy) => { 106 | // ignoring this event 107 | } 108 | }); 109 | 110 | if (this.sensorManager.registerListener(this.sensorEventListener, this.sensor, android.hardware.SensorManager.SENSOR_DELAY_UI)) { 111 | this.state = STATE.STARTING; 112 | } else { 113 | this.state = STATE.ERROR_FAILED_TO_START; 114 | reject("Failed to start"); 115 | } 116 | } else { 117 | this.state = STATE.ERROR_FAILED_TO_START; 118 | reject("Failed to start - No sensors found to register step counter listening to."); 119 | } 120 | } catch (ex) { 121 | reject(ex); 122 | } 123 | }); 124 | } 125 | 126 | public stopUpdates(): Promise { 127 | return new Promise((resolve, reject) => { 128 | try { 129 | if (this.sensorEventListener) { 130 | this.sensorManager.unregisterListener(this.sensorEventListener); 131 | this.state = STATE.STOPPED; 132 | } 133 | resolve(); 134 | } catch (ex) { 135 | reject(ex); 136 | } 137 | }); 138 | } 139 | 140 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NativeScript Pedometer plugin 2 | 3 | 4 | 5 | ## Supported platforms 6 | * iOS 8 (the newer the OS the more features are available) 7 | * Android, any device with a step counter sensor 8 | 9 | ## Installation 10 | From the command prompt go to your app's root folder and execute: 11 | 12 | ``` 13 | tns plugin add nativescript-pedometer 14 | ``` 15 | 16 | ## Demo app 17 | Want to dive in quickly? Check out [the demo app](demo)! Otherwise, continue reading. 18 | 19 | You can run the demo app from the root of the project by typing `npm run demo.ios.device` and you'll see this: 20 | 21 | 22 | 23 | 24 | ## API 25 | 26 | ### `isStepCountingAvailable` 27 | The key feature of this plugin is counting steps. And it's also the only feature that Android supports. 28 | 29 | ##### TypeScript 30 | ```js 31 | // require the plugin 32 | import { Pedometer } from "nativescript-pedometer"; 33 | 34 | // instantiate the plugin 35 | let pedometer = new Pedometer(); 36 | 37 | pedometer.isStepCountingAvailable().then(avail => { 38 | alert(avail ? "Yes" : "No"); 39 | }); 40 | ``` 41 | 42 | ##### JavaScript 43 | ```js 44 | // require the plugin 45 | var Pedometer = require("nativescript-pedometer").Pedometer; 46 | 47 | // instantiate the plugin 48 | var pedometer = new Pedometer(); 49 | 50 | pedometer.isStepCountingAvailable(function(avail) { 51 | alert(avail ? "Yes" : "No"); 52 | }); 53 | ``` 54 | 55 | > Providing only TypeScript examples from here on out, but usage it largely similar. Also, I'm leaving out the Promises where they don't add clarity to the code sample. 56 | 57 | ### `startUpdates` 58 | To start receiving step count updates from this moment forward you can invoke `startUpdates`. 59 | If you want historic data on iOS, pass in a custom `fromDate`. 60 | 61 | ```js 62 | pedometer.startUpdates({ 63 | fromDate: new Date(), // iOS only. Optional, default: now 64 | onUpdate: result => { 65 | // see the table below 66 | console.log(`Pedometer update: ${JSON.stringify(result)}`); 67 | } 68 | }).then(() => { 69 | console.log("Pedometer updates started."); 70 | }, err => { 71 | console.log("Error: " + err); 72 | }); 73 | ``` 74 | 75 | The `onUpdate` callback receives an object containing these properties: 76 | 77 | | Property | iOS? | Android? | Description | 78 | --- | --- | --- | --- 79 | | startDate | :white_check_mark: | :white_check_mark: | This is when recording of the currently returned data was started. | 80 | | endDate | :white_check_mark: | :white_check_mark: | This is when recording of the currently returned data was ended (usually: now). | 81 | | steps | :white_check_mark: | :white_check_mark: | Step count between startDate and endDate | 82 | | distance | :white_check_mark: | :white_medium_square: | The distance covered in meters between startDate and endDate. | 83 | | floorsAscended | :white_check_mark: | :white_medium_square: | The number of floors ascended between startDate and endDate. | 84 | | floorsDescended | :white_check_mark: | :white_medium_square: | The number of floors descended between startDate and endDate. | 85 | | currentPace | :white_check_mark: iOS9+ | :white_medium_square: | The current pace in seconds per meter. | 86 | | currentCadence | :white_check_mark: iOS9+ | :white_medium_square: | The current cadence in steps per second. | 87 | | averageActivePace | :white_check_mark: iOS10+ | :white_medium_square: | The average pace while active in seconds per meter between startDate and endDate. | 88 | 89 | If you want to check beforehand if things like `currentPace` are available, 90 | there's a few functions similar to `isStepCountingAvailable` that you can invoke: 91 | 92 | * `isDistanceAvailable` 93 | * `isFloorCountingAvailable` 94 | * `isPaceAvailable` 95 | * `isCadenceAvailable` 96 | 97 | ### `stopUpdates` 98 | You can wire up a Promise but there's no real need. 99 | 100 | ```js 101 | pedometer.stopUpdates(); 102 | ``` 103 | 104 | ### `query` (iOS) 105 | Instead of listening to "live" updates you can query historic data: 106 | 107 | ```js 108 | pedometer.query({ 109 | fromDate: new Date(new Date().getTime() - (1000 * 60 * 60)), 110 | toDate: new Date() // default 111 | }).then(result => { 112 | // see the table at 'startUpdates' above 113 | console.log(`Pedometer update: ${JSON.stringify(result)}`); 114 | }); 115 | ``` 116 | 117 | ### `startEventUpdates` (iOS) 118 | From iOS 10 onwards it's possible to get notified whenever the device detects a switch 119 | between a 'paused' and 'resumed' state (so starting/stopping walking). 120 | 121 | To check beforehand whether or not this feature is availbe, 122 | call `isEventTrackingAvailable` (which has a similar API to `isStepCountingAvailable`). 123 | 124 | ```js 125 | pedometer.startEventUpdates({ 126 | onUpdate: result => { 127 | // see the table below 128 | console.log("Pedometer event update: " + JSON.stringify(result)); 129 | } 130 | }).then(() => { 131 | console.log("Pedometer event updates started."); 132 | ); 133 | ``` 134 | 135 | The `onUpdate` callback receives an object containing these properties: 136 | 137 | | Property | Description | 138 | --- | --- 139 | | date | The moment the event occured. | 140 | | type | Either "pause" or "resume". | 141 | 142 | ## Changelog 143 | * 2.0.0 Android support added. 144 | * 1.0.0 Initial release, iOS only, but full featured. 145 | -------------------------------------------------------------------------------- /demo/app/main-page.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |