react-native-move-sdk 2.6.9 → 2.7.1-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/in/dolph/move/sdk/MoveSdkModule.kt +37 -2
- package/android/src/main/java/in/dolph/move/sdk/NativeMoveSdkWrapper.kt +24 -9
- package/ios/NativeModule/MoveSdk.swift +35 -12
- package/lib/commonjs/MoveSdk.js +363 -0
- package/lib/commonjs/MoveSdk.js.map +1 -0
- package/lib/commonjs/components/LazyMoveSdk.js +99 -0
- package/lib/commonjs/components/LazyMoveSdk.js.map +1 -0
- package/lib/commonjs/index.js +28 -325
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/MoveSdk.js +352 -0
- package/lib/module/MoveSdk.js.map +1 -0
- package/lib/module/components/LazyMoveSdk.js +80 -0
- package/lib/module/components/LazyMoveSdk.js.map +1 -0
- package/lib/module/index.js +3 -328
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/MoveSdk.d.ts +136 -0
- package/lib/typescript/components/LazyMoveSdk.d.ts +7 -0
- package/lib/typescript/index.d.ts +3 -134
- package/package.json +12 -9
- package/react-native-move-sdk.podspec +1 -1
- package/src/MoveSdk.ts +450 -0
- package/src/components/LazyMoveSdk.tsx +81 -0
- package/src/index.ts +3 -514
package/src/index.ts
CHANGED
|
@@ -1,514 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Platform,
|
|
5
|
-
EmitterSubscription,
|
|
6
|
-
} from 'react-native';
|
|
7
|
-
|
|
8
|
-
export type SdkState = 'UNINITIALIZED' | 'READY' | 'RUNNING';
|
|
9
|
-
export type TripState = 'UNKNOWN' | 'DRIVING' | 'HALT' | 'IDLE' | 'IGNORED';
|
|
10
|
-
export type AuthState = 'UNKNOWN' | 'VALID' | 'EXPIRED' | 'INVALID';
|
|
11
|
-
export type DrivingService =
|
|
12
|
-
| 'DISTRACTION_FREE_DRIVING'
|
|
13
|
-
| 'DRIVING_BEHAVIOUR'
|
|
14
|
-
| 'DEVICE_DISCOVERY';
|
|
15
|
-
export type WalkingService = 'WALKING_LOCATION';
|
|
16
|
-
export type OtherService = 'POINTS_OF_INTEREST';
|
|
17
|
-
export type TimelineDetectionService =
|
|
18
|
-
| 'DRIVING'
|
|
19
|
-
| 'CYCLING'
|
|
20
|
-
| 'WALKING'
|
|
21
|
-
| 'PLACES'
|
|
22
|
-
| 'PUBLIC_TRANSPORT'
|
|
23
|
-
| 'AUTOMATIC_IMPACT_DETECTION'
|
|
24
|
-
| 'ASSISTANCE_CALL'
|
|
25
|
-
| 'POINTS_OF_INTEREST';
|
|
26
|
-
|
|
27
|
-
export type ErrorReasons =
|
|
28
|
-
| 'BACKGROUND_LOCATION_PERMISSION_MISSING'
|
|
29
|
-
| 'LOCATION_PERMISSION_MISSING'
|
|
30
|
-
| 'MOTION_PERMISSION_MISSING'
|
|
31
|
-
| 'ACTIVITY_PERMISSION_MISSING'
|
|
32
|
-
| 'BATTERY_PERMISSION_MISSING'
|
|
33
|
-
| 'UNAUTHORIZED'
|
|
34
|
-
| 'INTERNET_PERMISSION_MISSING'
|
|
35
|
-
| 'PHONE_PERMISSION_MISSING'
|
|
36
|
-
| 'OVERLAY_PERMISSION_MISSING'
|
|
37
|
-
| 'NOTIFICATION_MISSING'
|
|
38
|
-
| 'ACCELEROMETER_MISSING'
|
|
39
|
-
| 'GOOGLE_PLAY_LOCATION_ACCURACY_MISSING'
|
|
40
|
-
| 'PRECISE_LOCATION_PERMISSION_MISSING';
|
|
41
|
-
|
|
42
|
-
export type WarningReasons =
|
|
43
|
-
| 'BACKGROUND_LOCATION_PERMISSION_MISSING'
|
|
44
|
-
| 'MOTION_PERMISSION_MISSING'
|
|
45
|
-
| 'ACTIVITY_PERMISSION_MISSING'
|
|
46
|
-
| 'BATTERY_OPTIMIZATION'
|
|
47
|
-
| 'BLUETOOTH_TURNED_OFF'
|
|
48
|
-
| 'BLUETOOTH_SCAN_PERMISSION_MISSING'
|
|
49
|
-
| 'BLUETOOTH_CONNECT_PERMISSION_MISSING'
|
|
50
|
-
| 'GOOGLE_PLAY_LOCATION_ACCURACY_MISSING'
|
|
51
|
-
| 'NOTIFICATION_PERMISSION_MISSING'
|
|
52
|
-
| 'FINE_LOCATION_PERMISSION_MISSING'
|
|
53
|
-
| 'BLUETOOTH_PERMISSION_MISSING'
|
|
54
|
-
| 'GPS_OFF'
|
|
55
|
-
| 'OFFLINE';
|
|
56
|
-
|
|
57
|
-
export type IssueListService =
|
|
58
|
-
| TimelineDetectionService
|
|
59
|
-
| DrivingService
|
|
60
|
-
| WalkingService;
|
|
61
|
-
|
|
62
|
-
export type IssueListItem<ReasonsType> = {
|
|
63
|
-
reasons: Array<ReasonsType>;
|
|
64
|
-
service?: IssueListService;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type ErrorListType = Array<IssueListItem<ErrorReasons>>;
|
|
68
|
-
|
|
69
|
-
export type WarningListType = Array<IssueListItem<WarningReasons>>;
|
|
70
|
-
|
|
71
|
-
export type ShutdownReturnType = 'NETWORK_ERROR' | 'SUCCESS' | 'UNINITIALIZED';
|
|
72
|
-
|
|
73
|
-
export type MoveSdkConfig = {
|
|
74
|
-
timelineDetectionServices: Array<TimelineDetectionService>;
|
|
75
|
-
drivingServices: Array<DrivingService>;
|
|
76
|
-
walkingServices: Array<WalkingService>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export type MoveSdkDeviceDiscovery = {
|
|
80
|
-
startDelay?: number;
|
|
81
|
-
duration?: number;
|
|
82
|
-
interval?: number;
|
|
83
|
-
stopScanOnFirstDiscovered?: boolean;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export type MoveSdkOptions = {
|
|
87
|
-
motionPermissionMandatory?: boolean;
|
|
88
|
-
backgroundLocationPermissionMandatory?: boolean;
|
|
89
|
-
overlayPermissionMandatory?: boolean;
|
|
90
|
-
useBackendConfig?: boolean;
|
|
91
|
-
deviceDiscovery?: MoveSdkDeviceDiscovery;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type MoveSdkAuth = {
|
|
95
|
-
userId: string;
|
|
96
|
-
accessToken: string;
|
|
97
|
-
refreshToken: string;
|
|
98
|
-
projectId: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export type NotificationConfig = {
|
|
102
|
-
title: string;
|
|
103
|
-
text: string;
|
|
104
|
-
channel: { id: string; name: string; description: string };
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export type MoveSdkAndroidConfig = {
|
|
108
|
-
notifications: {
|
|
109
|
-
recognitionNotification: NotificationConfig;
|
|
110
|
-
tripNotification: NotificationConfig;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export type ListenerSubscription = EmitterSubscription;
|
|
115
|
-
|
|
116
|
-
export type AuthStateEvent = {
|
|
117
|
-
state: AuthState;
|
|
118
|
-
accessToken?: string;
|
|
119
|
-
refreshToken?: string;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export type MoveSdkDeviceFilter = 'beacon' | 'paired';
|
|
123
|
-
|
|
124
|
-
export type MoveSdkDevice = {
|
|
125
|
-
name: string;
|
|
126
|
-
data: string;
|
|
127
|
-
id: string;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export type MoveScanResult = {
|
|
131
|
-
isDiscovered: boolean;
|
|
132
|
-
device: MoveSdkDevice;
|
|
133
|
-
name: string;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const { MoveSdk: NativeMoveSdk } = NativeModules;
|
|
137
|
-
const eventEmitter = new NativeEventEmitter(NativeMoveSdk);
|
|
138
|
-
|
|
139
|
-
export default class MoveSdk {
|
|
140
|
-
static READY: SdkState = 'READY';
|
|
141
|
-
static RUNNING: SdkState = 'RUNNING';
|
|
142
|
-
static UNINITIALIZED: SdkState = 'UNINITIALIZED';
|
|
143
|
-
|
|
144
|
-
static AUTH_EXPIRED: AuthState = 'EXPIRED';
|
|
145
|
-
static AUTH_VALID: AuthState = 'VALID';
|
|
146
|
-
static AUTH_UNKNOWN: AuthState = 'UNKNOWN';
|
|
147
|
-
|
|
148
|
-
static UNKNOWN: TripState = 'UNKNOWN';
|
|
149
|
-
static DRIVING: TripState = 'DRIVING';
|
|
150
|
-
static HALT: TripState = 'HALT';
|
|
151
|
-
static IDLE: TripState = 'IDLE';
|
|
152
|
-
static IGNORED: TripState = 'IGNORED';
|
|
153
|
-
|
|
154
|
-
static sdkStateFromNative(sdkState: SdkState): SdkState {
|
|
155
|
-
if (
|
|
156
|
-
[
|
|
157
|
-
MoveSdk.UNINITIALIZED,
|
|
158
|
-
MoveSdk.READY,
|
|
159
|
-
MoveSdk.RUNNING,
|
|
160
|
-
MoveSdk.UNINITIALIZED,
|
|
161
|
-
].includes(sdkState)
|
|
162
|
-
) {
|
|
163
|
-
return sdkState;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return MoveSdk.UNINITIALIZED;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
static tripStateFromNative(nativeTripState: TripState): TripState {
|
|
170
|
-
if (
|
|
171
|
-
[
|
|
172
|
-
MoveSdk.UNKNOWN,
|
|
173
|
-
MoveSdk.DRIVING,
|
|
174
|
-
MoveSdk.HALT,
|
|
175
|
-
MoveSdk.IDLE,
|
|
176
|
-
MoveSdk.IGNORED,
|
|
177
|
-
].includes(nativeTripState)
|
|
178
|
-
) {
|
|
179
|
-
return nativeTripState;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return MoveSdk.UNKNOWN;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
static authStateFromNative(nativeAuthState: AuthState): AuthState {
|
|
186
|
-
if ([MoveSdk.AUTH_VALID, MoveSdk.AUTH_EXPIRED].includes(nativeAuthState)) {
|
|
187
|
-
return nativeAuthState;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return MoveSdk.AUTH_UNKNOWN;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
static async setup(
|
|
194
|
-
config: MoveSdkConfig,
|
|
195
|
-
auth: MoveSdkAuth,
|
|
196
|
-
android: MoveSdkAndroidConfig,
|
|
197
|
-
options?: MoveSdkOptions
|
|
198
|
-
): Promise<void> {
|
|
199
|
-
const { timelineDetectionServices, drivingServices, walkingServices } =
|
|
200
|
-
config;
|
|
201
|
-
|
|
202
|
-
const { userId, projectId, accessToken, refreshToken } = auth;
|
|
203
|
-
|
|
204
|
-
let platformParams: Array<string | boolean> = [];
|
|
205
|
-
if (Platform.OS === 'android') {
|
|
206
|
-
const { notifications } = android;
|
|
207
|
-
|
|
208
|
-
const { tripNotification, recognitionNotification } = notifications;
|
|
209
|
-
|
|
210
|
-
if (!tripNotification || !recognitionNotification) {
|
|
211
|
-
throw new Error(
|
|
212
|
-
'MOVE SDK needs notification configuration for Android'
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
platformParams = [
|
|
217
|
-
recognitionNotification.title,
|
|
218
|
-
recognitionNotification.text,
|
|
219
|
-
recognitionNotification.channel.id,
|
|
220
|
-
recognitionNotification.channel.name,
|
|
221
|
-
recognitionNotification.channel.description,
|
|
222
|
-
tripNotification.title,
|
|
223
|
-
tripNotification.text,
|
|
224
|
-
tripNotification.channel.id,
|
|
225
|
-
tripNotification.channel.name,
|
|
226
|
-
tripNotification.channel.description,
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return await NativeMoveSdk.setup(
|
|
231
|
-
userId,
|
|
232
|
-
accessToken,
|
|
233
|
-
refreshToken,
|
|
234
|
-
projectId,
|
|
235
|
-
// Config
|
|
236
|
-
timelineDetectionServices,
|
|
237
|
-
drivingServices,
|
|
238
|
-
walkingServices,
|
|
239
|
-
options,
|
|
240
|
-
// Platform config
|
|
241
|
-
...platformParams
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
static allowMockLocations(allowMockLocations: boolean) {
|
|
246
|
-
NativeMoveSdk.allowMockLocations(allowMockLocations);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/* Deprecated */
|
|
250
|
-
static init() {
|
|
251
|
-
NativeMoveSdk.init();
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
static resolveError() {
|
|
255
|
-
NativeMoveSdk.resolveError();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
static async updateAuth(auth: MoveSdkAuth): Promise<void> {
|
|
259
|
-
const { userId, projectId, accessToken, refreshToken } = auth;
|
|
260
|
-
return await NativeMoveSdk.updateAuth(
|
|
261
|
-
userId,
|
|
262
|
-
accessToken,
|
|
263
|
-
refreshToken,
|
|
264
|
-
projectId
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
static startAutomaticDetection() {
|
|
269
|
-
NativeMoveSdk.startAutomaticDetection();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
static stopAutomaticDetection() {
|
|
273
|
-
NativeMoveSdk.stopAutomaticDetection();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
static forceTripRecognition(duration: number = 60000) {
|
|
277
|
-
NativeMoveSdk.forceTripRecognition(duration);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
static keepInForeground(enabled: boolean) {
|
|
281
|
-
if (Platform.OS === 'android') {
|
|
282
|
-
NativeMoveSdk.keepInForeground(enabled);
|
|
283
|
-
} else {
|
|
284
|
-
console.warn('MoveSdk.keepInForeground() is Android OS only.');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
static keepActive(enabled: boolean) {
|
|
289
|
-
if (Platform.OS === 'android') {
|
|
290
|
-
NativeMoveSdk.keepActive(enabled);
|
|
291
|
-
} else {
|
|
292
|
-
console.warn('MoveSdk.keepActive() is Android OS only.');
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
static async synchronizeUserData(): Promise<boolean> {
|
|
297
|
-
return await NativeMoveSdk.synchronizeUserData();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
static async getAuthState(): Promise<AuthState> {
|
|
301
|
-
const authState = await NativeMoveSdk.getAuthState();
|
|
302
|
-
return MoveSdk.authStateFromNative(authState);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
static async getState(): Promise<SdkState> {
|
|
306
|
-
const state = await NativeMoveSdk.getState();
|
|
307
|
-
return MoveSdk.sdkStateFromNative(state);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
static async getTripState(): Promise<TripState> {
|
|
311
|
-
const tripState = await NativeMoveSdk.getTripState();
|
|
312
|
-
return MoveSdk.tripStateFromNative(tripState);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
static async getErrors(): Promise<ErrorListType> {
|
|
316
|
-
return await NativeMoveSdk.getErrors();
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
static async getWarnings(): Promise<WarningListType> {
|
|
320
|
-
return await NativeMoveSdk.getWarnings();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
static async initiateAssistanceCall(): Promise<boolean> {
|
|
324
|
-
return await NativeMoveSdk.initiateAssistanceCall();
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
static setAssistanceMetaData(data: string) {
|
|
328
|
-
NativeMoveSdk.setAssistanceMetaData(data);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
static addTripStateListener(
|
|
332
|
-
tripStateChanged: (state: TripState) => void
|
|
333
|
-
): ListenerSubscription {
|
|
334
|
-
return eventEmitter.addListener('MOVE_SDK_TRIP_STATE', (event) =>
|
|
335
|
-
tripStateChanged(MoveSdk.tripStateFromNative(event.state))
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
static addTripStartListener(
|
|
340
|
-
tripStartTriggered: (start: Date) => void
|
|
341
|
-
): ListenerSubscription {
|
|
342
|
-
return eventEmitter.addListener('MOVE_SDK_TRIP_START', (start) =>
|
|
343
|
-
tripStartTriggered(new Date(Number(start)))
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
static addSdkStateListener(
|
|
348
|
-
sdkStateChanged: (state: SdkState) => void
|
|
349
|
-
): ListenerSubscription {
|
|
350
|
-
return eventEmitter.addListener('MOVE_SDK_STATE', (event) => {
|
|
351
|
-
sdkStateChanged(MoveSdk.sdkStateFromNative(event.state));
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
static addAuthStateListener(
|
|
356
|
-
authStateChanged: (event: AuthStateEvent) => void
|
|
357
|
-
): ListenerSubscription {
|
|
358
|
-
return eventEmitter.addListener('MOVE_SDK_AUTH_STATE', (event) => {
|
|
359
|
-
const transformedEvent = {
|
|
360
|
-
...event,
|
|
361
|
-
state: MoveSdk.authStateFromNative(event.state),
|
|
362
|
-
};
|
|
363
|
-
authStateChanged(transformedEvent);
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
static addErrorsListener(
|
|
368
|
-
errorsReceived: (errors: ErrorListType) => void
|
|
369
|
-
): ListenerSubscription {
|
|
370
|
-
return eventEmitter.addListener('MOVE_SDK_ERRORS', (event) => {
|
|
371
|
-
errorsReceived(event.errors);
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
static addWarningsListener(
|
|
376
|
-
warningsReceived: (warnings: WarningListType) => void
|
|
377
|
-
): ListenerSubscription {
|
|
378
|
-
return eventEmitter.addListener('MOVE_SDK_WARNINGS', (event) => {
|
|
379
|
-
warningsReceived(event.warnings);
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
static addAppEventListener(
|
|
384
|
-
appEventReceived: (event: string) => void
|
|
385
|
-
): ListenerSubscription {
|
|
386
|
-
return eventEmitter.addListener('MOVE_SDK_APP_EVENT', (event) => {
|
|
387
|
-
appEventReceived(event);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
static addRemoteConfigChangeListener(
|
|
392
|
-
configChangeReceived: (config: Array<IssueListService>) => void
|
|
393
|
-
): ListenerSubscription {
|
|
394
|
-
return eventEmitter.addListener('MOVE_SDK_CONFIG_UPDATE', (config) => {
|
|
395
|
-
configChangeReceived(config);
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
static version(): string {
|
|
400
|
-
return Platform.OS === 'android'
|
|
401
|
-
? NativeMoveSdk.getConstants().version
|
|
402
|
-
: 'Unknown';
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
static finishCurrentTrip() {
|
|
406
|
-
NativeMoveSdk.finishCurrentTrip();
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
static ignoreCurrentTrip() {
|
|
410
|
-
NativeMoveSdk.ignoreCurrentTrip();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
static requestMotionPermission() {
|
|
414
|
-
if (Platform.OS === 'ios') {
|
|
415
|
-
NativeMoveSdk.requestMotionPermission();
|
|
416
|
-
} else {
|
|
417
|
-
console.warn('MoveSdk.requestMotionPermission() is iOS only.');
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
static async shutdown(force: boolean = true): Promise<ShutdownReturnType> {
|
|
422
|
-
return await NativeMoveSdk.shutdown(force);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
static async getDeviceQualifier(): Promise<string | null> {
|
|
426
|
-
return NativeMoveSdk.getDeviceQualifier();
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
static async geocode(latitude: number, longitude: number): Promise<string> {
|
|
430
|
-
return await NativeMoveSdk.geocode(latitude, longitude);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
static async isAuthValid(): Promise<boolean> {
|
|
434
|
-
return await NativeMoveSdk.isAuthValid();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// **** PERMISSIONS MODULE START *****
|
|
438
|
-
|
|
439
|
-
static async canDrawOverlays(): Promise<boolean> {
|
|
440
|
-
return await NativeMoveSdk.canDrawOverlays();
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
static requestDrawOverlaysPermission() {
|
|
444
|
-
if (Platform.OS === 'android') {
|
|
445
|
-
NativeMoveSdk.requestDrawOverlaysPermission();
|
|
446
|
-
} else {
|
|
447
|
-
console.warn(
|
|
448
|
-
'MoveSdk.requestDrawOverlaysPermission() is Android OS only.'
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
static async isAppIgnoringBatteryOptimization(): Promise<boolean> {
|
|
454
|
-
return await NativeMoveSdk.isAppIgnoringBatteryOptimization();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
static requestAppIgnoringBatteryOptimization() {
|
|
458
|
-
if (Platform.OS === 'android') {
|
|
459
|
-
NativeMoveSdk.requestAppIgnoringBatteryOptimization();
|
|
460
|
-
} else {
|
|
461
|
-
console.warn(
|
|
462
|
-
'MoveSdk.requestAppIgnoringBatteryOptimization() is Android OS only.'
|
|
463
|
-
);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// **** PERMISSIONS MODULE END *****
|
|
468
|
-
|
|
469
|
-
static startScanningDevices(
|
|
470
|
-
sdkDevicesDetected: (state: Array<MoveSdkDevice>) => void,
|
|
471
|
-
filter: MoveSdkDeviceFilter[] = ['paired'],
|
|
472
|
-
uuid?: string,
|
|
473
|
-
manufacturerId?: number
|
|
474
|
-
): ListenerSubscription {
|
|
475
|
-
const subscription = eventEmitter.addListener(
|
|
476
|
-
'MOVE_SDK_DEVICES',
|
|
477
|
-
(devices) => {
|
|
478
|
-
sdkDevicesDetected(devices);
|
|
479
|
-
}
|
|
480
|
-
);
|
|
481
|
-
const subscriptionRemove = subscription.remove;
|
|
482
|
-
subscription.remove = () => {
|
|
483
|
-
NativeMoveSdk.stopScanningDevices();
|
|
484
|
-
subscriptionRemove();
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
NativeMoveSdk.startScanningDevices(filter, uuid, manufacturerId ?? -1);
|
|
488
|
-
return subscription;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
static async getRegisteredDevices(): Promise<Array<MoveSdkDevice>> {
|
|
492
|
-
return await NativeMoveSdk.getRegisteredDevices();
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
static async registerDevices(devices: Array<MoveSdkDevice>): Promise<boolean> {
|
|
496
|
-
return await NativeMoveSdk.registerDevices(devices);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
static async unregisterDevices(devices: Array<MoveSdkDevice>): Promise<boolean> {
|
|
500
|
-
return await NativeMoveSdk.unregisterDevices(devices);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
static requestBluetoothAlwaysUsagePermission(): void {
|
|
504
|
-
NativeMoveSdk.requestBluetoothAlwaysUsagePermission();
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
static addDeviceDiscoveryListener(
|
|
508
|
-
onScanResult: (state: Array<MoveScanResult>) => void
|
|
509
|
-
): ListenerSubscription {
|
|
510
|
-
return eventEmitter.addListener('MOVE_SDK_SCAN_RESULT', (results) => {
|
|
511
|
-
onScanResult(results);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
}
|
|
1
|
+
export * from './MoveSdk';
|
|
2
|
+
export { default } from './MoveSdk';
|
|
3
|
+
export { default as LazyMoveSdk } from './components/LazyMoveSdk';
|