hypertrack-sdk-react-native 7.19.0 → 8.0.0
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/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +154 -0
- package/README.md +25 -16
- package/android/build.gradle +141 -35
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +6 -0
- package/android/gradlew +185 -0
- package/android/gradlew.bat +89 -0
- package/android/src/main/AndroidManifest.xml +2 -3
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackModule.kt +284 -0
- package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +17 -0
- package/hypertrack-sdk-react-native.podspec +34 -15
- package/ios/{RNHyperTrack/RNHyperTrack.h → HyperTrack.h} +1 -2
- package/ios/HyperTrack.m +384 -0
- package/ios/{RNHyperTrack.xcodeproj → HyperTrackSdk.xcodeproj}/project.pbxproj +70 -99
- package/lib/commonjs/HyperTrack/HyperTrack.js +244 -0
- package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/HyperTrack/HyperTrack.js +230 -0
- package/lib/module/HyperTrack/HyperTrack.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/HyperTrack/HyperTrack.d.ts +161 -0
- package/lib/typescript/index.d.ts +4 -0
- package/package.json +145 -47
- package/src/HyperTrack/HyperTrack.ts +273 -0
- package/src/index.tsx +11 -0
- package/android/src/main/java/com/hypertrack/reactnative/androidsdk/HTSDKModule.java +0 -301
- package/android/src/main/java/com/hypertrack/reactnative/androidsdk/HTSDKPackage.java +0 -29
- package/ios/RNHyperTrack/RNHyperTrack.m +0 -312
- package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNHyperTrack.xcodeproj/project.xcworkspace/xcuserdata/tulushev.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNHyperTrack.xcodeproj/xcuserdata/tulushev.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/js/CriticalErrors.js +0 -97
- package/js/EventEmitter.js +0 -11
- package/js/HyperTrack.js +0 -130
- package/js/index.js +0 -13
package/js/CriticalErrors.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An error that we couldn't recognize.
|
|
3
|
-
*/
|
|
4
|
-
export const GENERAL = 0;
|
|
5
|
-
/**
|
|
6
|
-
* Publishable key is invalid. Check your key on hypertrack dashboard setup.
|
|
7
|
-
*/
|
|
8
|
-
export const INVALID_PUBLISHABLE_KEY = 1;
|
|
9
|
-
/**
|
|
10
|
-
* Your free trial ended or account was not renewed. Check your account on hypertrack dashboard.
|
|
11
|
-
*/
|
|
12
|
-
export const AUTHORIZATION_FAILED = 2;
|
|
13
|
-
/**
|
|
14
|
-
* Tracking won't start due to denied (or absent) permission.
|
|
15
|
-
*/
|
|
16
|
-
export const PERMISSION_DENIED = 3;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A base interface for errors in SDK.
|
|
21
|
-
*/
|
|
22
|
-
export type Error = {
|
|
23
|
-
/**
|
|
24
|
-
* Code of SDK error from {@link GENERAL}, {@link INVALID_PUBLISHABLE_KEY}, {@link AUTHORIZATION_FAILED}, {@link PERMISSION_DENIED}.
|
|
25
|
-
*/
|
|
26
|
-
code: number,
|
|
27
|
-
/**
|
|
28
|
-
* Message with additional information. Optional.
|
|
29
|
-
*/
|
|
30
|
-
message: ?string
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Geotags callback
|
|
34
|
-
|
|
35
|
-
/** Expected location is not supported on this platform */
|
|
36
|
-
export const PLATFORM_NOT_SUPPORTED = 0;
|
|
37
|
-
/** Expected vs actual location difference is greater then required */
|
|
38
|
-
export const LOCATION_MISMATCH = 1;
|
|
39
|
-
/** SDK can't get actual location from OS sensors */
|
|
40
|
-
export const LOCATION_NOT_AVAILABLE = 2;
|
|
41
|
-
/** Invalid arguments */
|
|
42
|
-
export const INVALID_ARGUMENTS = 3;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Interface for accessing adding geotag result.
|
|
46
|
-
* @property {number} code - is one of {@link PLATFORM_NOT_SUPPORTED}, {@link LOCATION_NOT_AVAILABLE}, {@link LOCATION_MISMATCH}, {@link INVALID_ARGUMENTS}
|
|
47
|
-
*/
|
|
48
|
-
export type GeotagError = { code: number }
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// The reason for why the SDK doesn't have a fresh location.
|
|
53
|
-
|
|
54
|
-
// The user has not chosen whether the app can use location services.
|
|
55
|
-
// SDK automatically asked for permissions.
|
|
56
|
-
export const LOCATION_PERMISSIONS_NOT_DETERMINED = "location_permissions_not_determined";
|
|
57
|
-
// The user has not chosen whether the app can use location services.
|
|
58
|
-
// SDK can't ask for permissions in background.
|
|
59
|
-
export const LOCATION_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = "location_permissions_cant_be_asked_in_background";
|
|
60
|
-
// Can't start tracking in background with When In Use location
|
|
61
|
-
// permissions. SDK will automatically start tracking when app will return
|
|
62
|
-
// to foreground.
|
|
63
|
-
export const LOCATION_PERMISSIONS_INSUFFICIENT_FOR_BACKGROUND = "location_permissions_insufficient_for_background";
|
|
64
|
-
// The app is not authorized to use location services.
|
|
65
|
-
export const LOCATION_PERMISSIONS_RESTRICTED = "location_permissions_restricted";
|
|
66
|
-
// The user didn't grant precise location permissions or downgraded permissions to imprecise.
|
|
67
|
-
export const LOCATION_PERMISSIONS_REDUCED_ACCURACY = "location_permissions_reduced_accuracy";
|
|
68
|
-
// The user denied location permissions.
|
|
69
|
-
export const LOCATION_PERMISSIONS_DENIED = "location_permissions_denied";
|
|
70
|
-
// The user disabled location services systemwide.
|
|
71
|
-
export const LOCATION_SERVICES_DISABLED = "location_services_disabled";
|
|
72
|
-
// The user has not chosen whether the app can use motion activity
|
|
73
|
-
// services. SDK automatically asked for permissions.
|
|
74
|
-
export const MOTION_ACTIVITY_PERMISSIONS_NOT_DETERMINED = "motion_activity_permissions_not_determined";
|
|
75
|
-
// The user has not chosen whether the app can use motion activity
|
|
76
|
-
// services. SDK can't ask for permissions in background.
|
|
77
|
-
export const MOTION_ACTIVITY_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND = "motion_activity_permissions_cant_be_asked_in_background";
|
|
78
|
-
// Motion activity permissions denied after SDK's initialization. Granting
|
|
79
|
-
// them will restart the app, so in effect, they are denied during this app's
|
|
80
|
-
// session.
|
|
81
|
-
export const MOTION_ACTIVITY_PERMISSIONS_DENIED = "motion_activity_permissions_denied";
|
|
82
|
-
// The user disabled motion services systemwide.
|
|
83
|
-
export const MOTION_ACTIVITY_SERVICES_DISABLED = "motion_activity_services_disabled";
|
|
84
|
-
// The SDK is not collecting locations because it's either not tracking or is unavailable.
|
|
85
|
-
export const NOT_RUNNING = "not_running";
|
|
86
|
-
// GPS satellites are not in view.
|
|
87
|
-
export const GPS_SIGNAL_LOST = "gps_signal_lost";
|
|
88
|
-
// The SDK started collecting locations and is waiting for OS location services to respond.
|
|
89
|
-
export const STARTING = "starting";
|
|
90
|
-
// The user enabled mock location app while mocking locations is prohibited.
|
|
91
|
-
export const LOCATION_MOCKED = "location_mocked";
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Interface for accessing location error value.
|
|
95
|
-
* @property {string} code - reason for why location is not available, one of {@link LOCATION_PERMISSIONS_NOT_DETERMINED}, {@link LOCATION_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND}, {@link LOCATION_PERMISSIONS_INSUFFICIENT_FOR_BACKGROUND}, {@link LOCATION_PERMISSIONS_RESTRICTED}, {@link LOCATION_PERMISSIONS_REDUCED_ACCURACY}, {@link LOCATION_SERVICES_DISABLED}, {@link MOTION_ACTIVITY_PERMISSIONS_NOT_DETERMINED}, {@link MOTION_ACTIVITY_PERMISSIONS_CANT_BE_ASKED_IN_BACKGROUND}, {@link MOTION_ACTIVITY_PERMISSIONS_DENIED}, {@link MOTION_ACTIVITY_SERVICES_DISABLED}, {@link GPS_SIGNAL_LOST}, {@link STARTING}
|
|
96
|
-
*/
|
|
97
|
-
export type LocationError = { code: string }
|
package/js/EventEmitter.js
DELETED
package/js/HyperTrack.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import EventEmitter from './EventEmitter';
|
|
4
|
-
import {Error, GeotagError, LocationError} from './CriticalErrors';
|
|
5
|
-
|
|
6
|
-
const HyperTrack = require('react-native').NativeModules.HyperTrack;
|
|
7
|
-
|
|
8
|
-
class HyperTrackAPI {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Returns a string which is used by HyperTrack to uniquely identify the user.
|
|
12
|
-
*/
|
|
13
|
-
getDeviceID(): Promise<string> {
|
|
14
|
-
return HyperTrack.getDeviceID();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Determine whether the SDK is tracking the movement of the user.
|
|
19
|
-
* @return {boolean} Whether the user's movement data is getting tracked or not.
|
|
20
|
-
*/
|
|
21
|
-
isTracking(): Promise<boolean> {
|
|
22
|
-
return HyperTrack.isTracking();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Update device state from server.
|
|
27
|
-
*/
|
|
28
|
-
syncDeviceSettings() {
|
|
29
|
-
return HyperTrack.syncDeviceSettings();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Start or resume tracking location and activity events.
|
|
34
|
-
*/
|
|
35
|
-
startTracking() {
|
|
36
|
-
HyperTrack.startTracking();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Stops the SDK from listening to the user's movement updates and recording any data.
|
|
41
|
-
*/
|
|
42
|
-
stopTracking() {
|
|
43
|
-
HyperTrack.stopTracking();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/// The current location of the user or an outage reason.
|
|
47
|
-
getLocation(): Promise<LocationError|GeolocationCoordinates> {
|
|
48
|
-
return HyperTrack.getLocation();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Registers tracking state callbacks.
|
|
53
|
-
* @param {Object} component - Instance of your component.
|
|
54
|
-
* @param {function} onError - Tracking state callback for error events.
|
|
55
|
-
* @param {function} onStart - Tracking state callback for start event.
|
|
56
|
-
* @param {function} onStop - Tracking state callback for stop event.
|
|
57
|
-
*/
|
|
58
|
-
registerTrackingListeners(component: Object,
|
|
59
|
-
onError: (error: ?Error) => void,
|
|
60
|
-
onStart: () => void,
|
|
61
|
-
onStop: () => void) {
|
|
62
|
-
if (onError) component.onErrorHyperTrackSubscription = EventEmitter.addListener('onTrackingErrorHyperTrack', onError);
|
|
63
|
-
if (onStart) component.onStartHyperTrackSubscription = EventEmitter.addListener('onTrackingStartHyperTrack', onStart);
|
|
64
|
-
if (onStop) component.onStopHyperTrackSubscription = EventEmitter.addListener('onTrackingStopHyperTrack', onStop);
|
|
65
|
-
HyperTrack.subscribeOnEvents();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Removes tracking state callbacks.
|
|
70
|
-
* @param {Object} component - Instance of your component.
|
|
71
|
-
*/
|
|
72
|
-
unregisterTrackingListeners(component: Object) {
|
|
73
|
-
component.onErrorHyperTrackSubscription && component.onErrorHyperTrackSubscription.remove();
|
|
74
|
-
component.onStartHyperTrackSubscription && component.onStartHyperTrackSubscription.remove();
|
|
75
|
-
component.onStopHyperTrackSubscription && component.onStopHyperTrackSubscription.remove();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Send device name to HyperTrack
|
|
80
|
-
* @param {string} name - Device name you want to see in the Dashboard.
|
|
81
|
-
*/
|
|
82
|
-
setDeviceName(name: string) {
|
|
83
|
-
HyperTrack.setDeviceName(name);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Send metadata details to HyperTrack
|
|
88
|
-
* @param {Object} data - Send extra device information.
|
|
89
|
-
*/
|
|
90
|
-
setMetadata(data: Object) {
|
|
91
|
-
HyperTrack.setMetadata(data);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated
|
|
96
|
-
* Set a trip marker
|
|
97
|
-
* @param {Object} data - Include anything that can be parsed into JSON.
|
|
98
|
-
*/
|
|
99
|
-
setTripMarker(data: Object) {
|
|
100
|
-
HyperTrack.setTripMarker(data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Add geotag
|
|
105
|
-
* @param {Object} data - Include anything that can be parsed into JSON.
|
|
106
|
-
* @param {GeolocationCoordinates} expectedLocation? - optional location of a place,
|
|
107
|
-
* where the action is supposed to happen.
|
|
108
|
-
*/
|
|
109
|
-
addGeotag(data: Object, expectedLocation?: GeolocationCoordinates): Promise<GeotagError|GeolocationCoordinates> {
|
|
110
|
-
return HyperTrack.addGeotag(data, expectedLocation || {});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
module.exports = {
|
|
114
|
-
/**
|
|
115
|
-
* Initialize the HyperTrack SDK
|
|
116
|
-
* @param {string} publishableKey - A unique String that is used to identify your account with HyperTrack.
|
|
117
|
-
* @param {boolean} automaticallyRequestPermissions - If true, SDK automatically triggers location and motion activity permissions dialogs when tracking starts.
|
|
118
|
-
*/
|
|
119
|
-
async createInstance(publishableKey, automaticallyRequestPermissions = true): Promise<HyperTrackAPI> {
|
|
120
|
-
await HyperTrack.initialize(publishableKey, false, automaticallyRequestPermissions);
|
|
121
|
-
return new HyperTrackAPI();
|
|
122
|
-
},
|
|
123
|
-
/**
|
|
124
|
-
* Enables debug log output. This is very verbose, so you shouldn't use this for
|
|
125
|
-
* production build.
|
|
126
|
-
*/
|
|
127
|
-
enableDebugLogging(enable) {
|
|
128
|
-
HyperTrack.enableDebugLogging(enable);
|
|
129
|
-
},
|
|
130
|
-
};
|