0.0.13 • Published 4 years ago
react-native-fitness-watcher v0.0.13
react-native-fitness-watcher
NOTE: This is a package for custom fitness watch and cannot be use for other BLE devices.
Getting started
$ npm install react-native-fitness-watcher --save
Mostly automatic installation (Skip this step for React Native 0.60 and above.)
$ react-native link react-native-fitness-watcher
Manual installation
iOS (Skip this step for React Native 0.60 and above.)
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-fitness-watcher
and addFitnessWatcher.xcodeproj
- In XCode, in the project navigator, select your project. Add
libFitnessWatcher.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android (Skip this step for React Native 0.60 and above.)
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.FitnessWatcherPackage;
to the imports at the top of the file - Add
new FitnessWatcherPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-fitness-watcher' project(':react-native-fitness-watcher').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fitness-watcher/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-fitness-watcher')
Usage
import FitnessWatcher from 'react-native-fitness-watcher';
IMPORTANT: YOU MUST ALSO ENSURE THAT THE PROPER PERMISSIONS MUST BE GRANTED FOR THE MODULE TO WORK.
FOR ANDROID PERMISSIONS, ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION
Refer to https://facebook.github.io/react-native/docs/permissionsandroid on how to prompt user for permissions.
//Initialize the Fitness Watcher
FitnessWatcher.initializeFitnessWatcher()
//Get list of devices (The device's name is most likely L8-R7)
FitnessWatcher.getListOfDevices((callbackResult => (return callbackResult)))
//Connect to device with deviceAddress
FitnessWatcher.connectToBLEDevice(deviceAddress: string, (callbackResult => (return callbackResult)))