-
Notifications
You must be signed in to change notification settings - Fork 9
/
pedometer.js
62 lines (50 loc) · 1.46 KB
/
pedometer.js
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
51
52
53
54
55
56
57
58
59
60
61
62
'use strict';
import { NativeModules, NativeEventEmitter } from 'react-native';
const { RNPedometer } = NativeModules;
const EventEmitter = new NativeEventEmitter(RNPedometer);
let subscription;
function isStepCountingAvailable(callback) {
RNPedometer.isStepCountingAvailable(callback);
}
function isDistanceAvailable(callback) {
RNPedometer.isDistanceAvailable(callback);
}
function isPaceAvailable(callback) {
RNPedometer.isPaceAvailable(callback);
}
function isCadenceAvailable(callback) {
RNPedometer.isCadenceAvailable(callback);
}
function isPedometerEventTrackingAvailable(callback) {
RNPedometer.isPedometerEventTrackingAvailable(callback);
}
function queryPedometerDataBetweenDates(startDate, endDate, handler) {
RNPedometer.queryPedometerDataBetweenDates(startDate, endDate, handler);
}
function stopPedometerUpdates() {
RNPedometer.stopPedometerUpdates();
if (subscription) {
subscription.remove();
}
}
function startPedometerUpdatesFromDate(date, handler) {
RNPedometer.startPedometerUpdatesFromDate(date);
subscription = EventEmitter.addListener(
'pedometerDataDidUpdate',
handler
);
}
function authorizationStatus(callback) {
RNPedometer.authorizationStatus(callback);
}
export default {
isStepCountingAvailable,
isDistanceAvailable,
isPaceAvailable,
isCadenceAvailable,
isPedometerEventTrackingAvailable,
queryPedometerDataBetweenDates,
stopPedometerUpdates,
startPedometerUpdatesFromDate,
authorizationStatus
}