hypertrack-sdk-react-native 10.0.3 → 11.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +2 -2
  4. package/android/build.gradle +5 -1
  5. package/android/gradle.properties +1 -1
  6. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +80 -115
  7. package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +23 -3
  8. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +87 -220
  9. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +11 -9
  10. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +216 -132
  11. package/android/src/main/java/com/reactnativehypertracksdk/common/{Result.kt → WrapperResult.kt} +9 -7
  12. package/hypertrack-sdk-react-native.podspec +1 -1
  13. package/ios/HyperTrackReactNativePlugin.m +13 -11
  14. package/ios/HyperTrackReactNativePlugin.swift +141 -114
  15. package/ios/common/DictionaryDecoder.swift +5 -5
  16. package/ios/common/HyperTrackSDKWrapper.swift +44 -80
  17. package/ios/common/SDKMethod.swift +13 -12
  18. package/ios/common/Serialization.swift +190 -245
  19. package/lib/commonjs/HyperTrack/HyperTrack.js +224 -124
  20. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  21. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js +13 -17
  22. package/lib/commonjs/HyperTrack/data_types/HyperTrackError.js.map +1 -1
  23. package/lib/commonjs/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -1
  24. package/lib/commonjs/HyperTrack/data_types/internal/Metadata.js +2 -0
  25. package/lib/commonjs/HyperTrack/data_types/internal/Metadata.js.map +1 -0
  26. package/lib/commonjs/HyperTrack/data_types/internal/Name.js +2 -0
  27. package/lib/commonjs/HyperTrack/data_types/internal/Name.js.map +1 -0
  28. package/lib/commonjs/index.js +0 -7
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/module/HyperTrack/HyperTrack.js +224 -124
  31. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  32. package/lib/module/HyperTrack/data_types/HyperTrackError.js +13 -17
  33. package/lib/module/HyperTrack/data_types/HyperTrackError.js.map +1 -1
  34. package/lib/module/HyperTrack/data_types/internal/HyperTrackErrorInternal.js.map +1 -1
  35. package/lib/module/HyperTrack/data_types/internal/Metadata.js +2 -0
  36. package/lib/module/HyperTrack/data_types/internal/Metadata.js.map +1 -0
  37. package/lib/module/HyperTrack/data_types/internal/Name.js +2 -0
  38. package/lib/module/HyperTrack/data_types/internal/Name.js.map +1 -0
  39. package/lib/module/index.js +0 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/typescript/HyperTrack/HyperTrack.d.ts +106 -54
  42. package/lib/typescript/HyperTrack/data_types/HyperTrackError.d.ts +59 -17
  43. package/lib/typescript/HyperTrack/data_types/internal/HyperTrackErrorInternal.d.ts +1 -1
  44. package/lib/typescript/HyperTrack/data_types/internal/Metadata.d.ts +4 -0
  45. package/lib/typescript/HyperTrack/data_types/internal/Name.d.ts +7 -0
  46. package/lib/typescript/index.d.ts +0 -1
  47. package/package.json +1 -1
  48. package/src/HyperTrack/HyperTrack.ts +281 -161
  49. package/src/HyperTrack/data_types/HyperTrackError.ts +73 -18
  50. package/src/HyperTrack/data_types/internal/HyperTrackErrorInternal.ts +3 -3
  51. package/src/HyperTrack/data_types/internal/Metadata.ts +4 -0
  52. package/src/HyperTrack/data_types/internal/Name.ts +7 -0
  53. package/src/index.tsx +0 -1
  54. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackError.kt +0 -28
  55. package/android/src/main/java/com/reactnativehypertracksdk/common/LocationError.kt +0 -9
  56. package/android/src/main/java/com/reactnativehypertracksdk/common/SdkInitParams.kt +0 -44
  57. package/ios/common/HyperTrackError.swift +0 -20
  58. package/ios/common/SDKInitParams.swift +0 -13
  59. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js +0 -2
  60. package/lib/commonjs/HyperTrack/data_types/SdkInitParams.js.map +0 -1
  61. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js +0 -2
  62. package/lib/commonjs/HyperTrack/data_types/internal/DeviceName.js.map +0 -1
  63. package/lib/module/HyperTrack/data_types/SdkInitParams.js +0 -2
  64. package/lib/module/HyperTrack/data_types/SdkInitParams.js.map +0 -1
  65. package/lib/module/HyperTrack/data_types/internal/DeviceName.js +0 -2
  66. package/lib/module/HyperTrack/data_types/internal/DeviceName.js.map +0 -1
  67. package/lib/typescript/HyperTrack/data_types/SdkInitParams.d.ts +0 -25
  68. package/lib/typescript/HyperTrack/data_types/internal/DeviceName.d.ts +0 -4
  69. package/src/HyperTrack/data_types/SdkInitParams.ts +0 -28
  70. package/src/HyperTrack/data_types/internal/DeviceName.ts +0 -4
@@ -1,24 +1,20 @@
1
1
  // enum naming convention is ignored to make datatype sync
2
2
  // across platforms easier
3
3
  export let HyperTrackError = /*#__PURE__*/function (HyperTrackError) {
4
- HyperTrackError["gpsSignalLost"] = "gpsSignalLost";
5
- HyperTrackError["locationMocked"] = "locationMocked";
6
- HyperTrackError["locationPermissionsDenied"] = "locationPermissionsDenied";
7
- HyperTrackError["locationPermissionsInsufficientForBackground"] = "locationPermissionsInsufficientForBackground";
8
- HyperTrackError["locationPermissionsNotDetermined"] = "locationPermissionsNotDetermined";
9
- HyperTrackError["locationPermissionsReducedAccuracy"] = "locationPermissionsReducedAccuracy";
10
- HyperTrackError["locationPermissionsProvisional"] = "locationPermissionsProvisional";
11
- HyperTrackError["locationPermissionsRestricted"] = "locationPermissionsRestricted";
12
- HyperTrackError["locationServicesDisabled"] = "locationServicesDisabled";
13
- HyperTrackError["locationServicesUnavailable"] = "locationServicesUnavailable";
14
- HyperTrackError["motionActivityPermissionsNotDetermined"] = "motionActivityPermissionsNotDetermined";
15
- HyperTrackError["motionActivityPermissionsDenied"] = "motionActivityPermissionsDenied";
16
- HyperTrackError["motionActivityServicesDisabled"] = "motionActivityServicesDisabled";
17
- HyperTrackError["motionActivityServicesUnavailable"] = "motionActivityServicesUnavailable";
18
- HyperTrackError["motionActivityPermissionsRestricted"] = "motionActivityPermissionsRestricted";
19
- HyperTrackError["networkConnectionUnavailable"] = "networkConnectionUnavailable";
20
- HyperTrackError["invalidPublishableKey"] = "invalidPublishableKey";
21
4
  HyperTrackError["blockedFromRunning"] = "blockedFromRunning";
5
+ HyperTrackError["invalidPublishableKey"] = "invalidPublishableKey";
6
+ HyperTrackError["locationMocked"] = "location.mocked";
7
+ HyperTrackError["locationServicesDisabled"] = "location.servicesDisabled";
8
+ HyperTrackError["locationServicesUnavailable"] = "location.servicesUnavailable";
9
+ HyperTrackError["locationSignalLost"] = "location.signalLost";
10
+ HyperTrackError["noExemptionFromBackgroundStartRestrictions"] = "noExemptionFromBackgroundStartRestrictions";
11
+ HyperTrackError["permissionsLocationDenied"] = "permissions.location.denied";
12
+ HyperTrackError["permissionsLocationInsufficientForBackground"] = "permissions.location.insufficientForBackground";
13
+ HyperTrackError["permissionsLocationNotDetermined"] = "permissions.location.notDetermined";
14
+ HyperTrackError["permissionsLocationProvisional"] = "permissions.location.provisional";
15
+ HyperTrackError["permissionsLocationReducedAccuracy"] = "permissions.location.reducedAccuracy";
16
+ HyperTrackError["permissionsLocationRestricted"] = "permissions.location.restricted";
17
+ HyperTrackError["permissionsNotificationsDenied"] = "permissions.notifications.denied";
22
18
  return HyperTrackError;
23
19
  }({});
24
20
  //# sourceMappingURL=HyperTrackError.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HyperTrackError"],"sources":["HyperTrackError.ts"],"sourcesContent":["// enum naming convention is ignored to make datatype sync\n// across platforms easier\nexport enum HyperTrackError {\n gpsSignalLost = \"gpsSignalLost\",\n locationMocked = \"locationMocked\",\n locationPermissionsDenied = \"locationPermissionsDenied\",\n locationPermissionsInsufficientForBackground = \"locationPermissionsInsufficientForBackground\",\n locationPermissionsNotDetermined = \"locationPermissionsNotDetermined\",\n locationPermissionsReducedAccuracy = \"locationPermissionsReducedAccuracy\",\n locationPermissionsProvisional = \"locationPermissionsProvisional\",\n locationPermissionsRestricted = \"locationPermissionsRestricted\",\n locationServicesDisabled = \"locationServicesDisabled\",\n locationServicesUnavailable = \"locationServicesUnavailable\",\n motionActivityPermissionsNotDetermined = \"motionActivityPermissionsNotDetermined\",\n motionActivityPermissionsDenied = \"motionActivityPermissionsDenied\",\n motionActivityServicesDisabled = \"motionActivityServicesDisabled\",\n motionActivityServicesUnavailable = \"motionActivityServicesUnavailable\",\n motionActivityPermissionsRestricted = \"motionActivityPermissionsRestricted\",\n networkConnectionUnavailable = \"networkConnectionUnavailable\",\n invalidPublishableKey = \"invalidPublishableKey\",\n blockedFromRunning = \"blockedFromRunning\"\n}\n"],"mappings":"AAAA;AACA;AACA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA"}
1
+ {"version":3,"names":["HyperTrackError"],"sources":["HyperTrackError.ts"],"sourcesContent":["// enum naming convention is ignored to make datatype sync\n// across platforms easier\nexport enum HyperTrackError {\n /**\n * The SDK was remotely blocked from running.\n */\n blockedFromRunning = 'blockedFromRunning',\n\n /**\n * The publishable key is invalid.\n */\n invalidPublishableKey = 'invalidPublishableKey',\n\n /**\n * The user enabled mock location app while mocking locations is prohibited.\n */\n locationMocked = 'location.mocked',\n\n /**\n * The user disabled location services systemwide.\n */\n locationServicesDisabled = 'location.servicesDisabled',\n\n /**\n * [Android only] The device doesn't have location services.\n */\n locationServicesUnavailable = 'location.servicesUnavailable',\n\n /**\n * GPS satellites are not in view.\n */\n locationSignalLost = 'location.signalLost',\n\n /**\n * [Android only] The SDK wasn't able to start tracking because of the limitations imposed by the OS.\n * The exempt from background execution conditions weren't met.\n * {@link https://developer.android.com/guide/components/foreground-services#background-start-restriction-exemptions}\n */\n noExemptionFromBackgroundStartRestrictions = 'noExemptionFromBackgroundStartRestrictions',\n\n /**\n * The user denied location permissions.\n */\n permissionsLocationDenied = 'permissions.location.denied',\n\n /**\n * Can’t start tracking in background with When In Use location permissions.\n * SDK will automatically start tracking when app will return to foreground.\n */\n permissionsLocationInsufficientForBackground = 'permissions.location.insufficientForBackground',\n\n /**\n * [iOS only] The user has not chosen whether the app can use location services.\n */\n permissionsLocationNotDetermined = 'permissions.location.notDetermined',\n\n /**\n * [iOS only] The app is in Provisional Always authorization state, which stops sending locations when app is in background.\n */\n permissionsLocationProvisional = 'permissions.location.provisional',\n\n /**\n * The user didn't grant precise location permissions or downgraded permissions to imprecise.\n */\n permissionsLocationReducedAccuracy = 'permissions.location.reducedAccuracy',\n\n /**\n * [iOS only] The app is not authorized to use location services.\n */\n permissionsLocationRestricted = 'permissions.location.restricted',\n\n /**\n * [Android only] The user denied notification permissions needed to display a persistent notification\n * needed for foreground location tracking.\n */\n permissionsNotificationsDenied = 'permissions.notifications.denied',\n}\n"],"mappings":"AAAA;AACA;AACA,WAAYA,eAAe,0BAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAfA,eAAe;EAAA,OAAfA,eAAe;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["HyperTrackErrorInternal.ts"],"sourcesContent":["export type HyperTrackErrorInternal = {\n type: \"hyperTrackError\",\n value: string\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["HyperTrackErrorInternal.ts"],"sourcesContent":["export type HyperTrackErrorInternal = {\n type: 'error';\n value: string;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["Metadata.ts"],"sourcesContent":["export type Metadata = {\n type: 'metadata';\n value: Object;\n};\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=Name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["Name.ts"],"sourcesContent":["/**\n * Device name\n */\nexport type Name = {\n type: 'name';\n value: string;\n};\n"],"mappings":""}
@@ -6,6 +6,5 @@ export { NotRunning, Starting } from './HyperTrack/data_types/internal/LocationE
6
6
  export { LocationError, Errors } from './HyperTrack/data_types/LocationError';
7
7
  export { LocationWithDeviation } from './HyperTrack/data_types/LocationWithDeviation';
8
8
  export { Location } from './HyperTrack/data_types/Location';
9
- export { SdkInitParams } from './HyperTrack/data_types/SdkInitParams';
10
9
  export { Result, Success, Failure } from './HyperTrack/data_types/Result';
11
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HyperTrack","HyperTrackError","NotRunning","Starting","LocationError","Errors","LocationWithDeviation","Location","SdkInitParams","Result","Success","Failure"],"sources":["index.tsx"],"sourcesContent":["import HyperTrack from './HyperTrack/HyperTrack';\nexport default HyperTrack;\nexport { HyperTrack };\n\nexport { HyperTrackError } from './HyperTrack/data_types/HyperTrackError';\nexport {\n NotRunning,\n Starting,\n} from './HyperTrack/data_types/internal/LocationErrorInternal';\nexport { LocationError, Errors } from './HyperTrack/data_types/LocationError';\nexport { LocationWithDeviation } from './HyperTrack/data_types/LocationWithDeviation';\nexport { Location } from './HyperTrack/data_types/Location';\nexport { SdkInitParams } from './HyperTrack/data_types/SdkInitParams';\nexport { Result, Success, Failure } from './HyperTrack/data_types/Result';\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,yBAAyB;AAChD,eAAeA,UAAU;AACzB,SAASA,UAAU;AAEnB,SAASC,eAAe,QAAQ,yCAAyC;AACzE,SACEC,UAAU,EACVC,QAAQ,QACH,wDAAwD;AAC/D,SAASC,aAAa,EAAEC,MAAM,QAAQ,uCAAuC;AAC7E,SAASC,qBAAqB,QAAQ,+CAA+C;AACrF,SAASC,QAAQ,QAAQ,kCAAkC;AAC3D,SAASC,aAAa,QAAQ,uCAAuC;AACrE,SAASC,MAAM,EAAEC,OAAO,EAAEC,OAAO,QAAQ,gCAAgC"}
1
+ {"version":3,"names":["HyperTrack","HyperTrackError","NotRunning","Starting","LocationError","Errors","LocationWithDeviation","Location","Result","Success","Failure"],"sources":["index.tsx"],"sourcesContent":["import HyperTrack from './HyperTrack/HyperTrack';\nexport default HyperTrack;\nexport { HyperTrack };\n\nexport { HyperTrackError } from './HyperTrack/data_types/HyperTrackError';\nexport {\n NotRunning,\n Starting,\n} from './HyperTrack/data_types/internal/LocationErrorInternal';\nexport { LocationError, Errors } from './HyperTrack/data_types/LocationError';\nexport { LocationWithDeviation } from './HyperTrack/data_types/LocationWithDeviation';\nexport { Location } from './HyperTrack/data_types/Location';\nexport { Result, Success, Failure } from './HyperTrack/data_types/Result';\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,yBAAyB;AAChD,eAAeA,UAAU;AACzB,SAASA,UAAU;AAEnB,SAASC,eAAe,QAAQ,yCAAyC;AACzE,SACEC,UAAU,EACVC,QAAQ,QACH,wDAAwD;AAC/D,SAASC,aAAa,EAAEC,MAAM,QAAQ,uCAAuC;AAC7E,SAASC,qBAAqB,QAAQ,+CAA+C;AACrF,SAASC,QAAQ,QAAQ,kCAAkC;AAC3D,SAASC,MAAM,EAAEC,OAAO,EAAEC,OAAO,QAAQ,gCAAgC"}
@@ -1,82 +1,112 @@
1
+ import { EmitterSubscription } from 'react-native';
1
2
  import { HyperTrackError } from './data_types/HyperTrackError';
2
3
  import type { Location } from './data_types/Location';
3
4
  import type { LocationError } from './data_types/LocationError';
4
- import type { SdkInitParams } from './data_types/SdkInitParams';
5
- import type { Result } from './data_types/Result';
6
5
  import type { LocationWithDeviation } from './data_types/LocationWithDeviation';
6
+ import type { Result } from './data_types/Result';
7
7
  export default class HyperTrack {
8
- private constructor();
8
+ private static locateSubscription;
9
9
  /**
10
- * Creates an SDK instance
10
+ * Adds a new geotag
11
11
  *
12
- * @param publishableKey publishable key provided in HyperTrack’s dashboard setup page
13
- * @param sdkInitParams
14
- * @returns HyperTrack instance
12
+ * @param {Object} data - Geotad data JSON
13
+ * @returns current location if success or LocationError if failure
15
14
  */
16
- static initialize(publishableKey: string, sdkInitParams?: SdkInitParams): Promise<HyperTrack>;
15
+ static addGeotag(data: Object): Promise<Result<Location, LocationError>>;
16
+ /**
17
+ * Adds a new geotag with expected location
18
+ *
19
+ * @param {Object} data - Geotad data JSON
20
+ * @param {Location} expectedLocation - Expected location
21
+ * @returns location with deviation if success or LocationError if failure
22
+ */
23
+ static addGeotag(data: Object, expectedLocation: Location): Promise<Result<LocationWithDeviation, LocationError>>;
17
24
  /**
18
25
  * Returns a string that is used to uniquely identify the device
26
+ *
27
+ * @returns {string} Device ID
19
28
  */
20
- getDeviceId(): Promise<string>;
29
+ static getDeviceId(): Promise<string>;
21
30
  /**
22
- * Reflects availability of the device for the Nearby search
31
+ * Returns a list of errors that blocks SDK from tracking
23
32
  *
24
- * @returns true when is available or false when unavailable
33
+ * @returns {HyperTrackError[]} List of errors
25
34
  */
26
- isAvailable(): Promise<boolean>;
35
+ static getErrors(): Promise<HyperTrackError[]>;
27
36
  /**
28
- * Sets the availability of the device for the Nearby search
37
+ * Reflects availability of the device for the Nearby search
29
38
  *
30
- * @param availability true when is available or false when unavailable
39
+ * @returns true when is available or false when unavailable
31
40
  */
32
- setAvailability(isAvailable: boolean): void;
41
+ static getIsAvailable(): Promise<boolean>;
33
42
  /**
34
43
  * Reflects the tracking intent for the device
35
44
  *
36
- * @return {boolean} Whether the user's movement data is getting tracked or not.
45
+ * @returns {boolean} Whether the user's movement data is getting tracked or not.
37
46
  */
38
- isTracking(): Promise<boolean>;
47
+ static getIsTracking(): Promise<boolean>;
39
48
  /**
40
- * Syncs the device state with the HyperTrack servers
49
+ * Reflects the current location of the user or an outage reason
41
50
  */
42
- sync(): void;
51
+ static getLocation(): Promise<Result<Location, LocationError>>;
43
52
  /**
44
- * Expresses an intent to start location tracking for the device
53
+ * Gets the metadata that is set for the device
54
+ *
55
+ * @returns {Object} Metadata JSON
45
56
  */
46
- startTracking(): void;
57
+ static getMetadata(): Promise<Object>;
47
58
  /**
48
- * Stops location tracking immediately
59
+ * Gets the name that is set for the device
60
+ *
61
+ * @returns {string} Device name
49
62
  */
50
- stopTracking(): void;
63
+ static getName(): Promise<string>;
51
64
  /**
52
- * Reflects the current location of the user or an outage reason
65
+ * Requests one-time location update and returns the location once it is available, or error.
66
+ *
67
+ * Only one locate subscription can be active at a time. If you re-subscribe, the old EmitterSubscription
68
+ * will be automaticaly removed.
69
+ *
70
+ * This method will start location tracking if called, and will stop it when the location is received or
71
+ * the subscription is cancelled. If any other tracking intent is present (e.g. isAvailable is set to `true`),
72
+ * the tracking will not be stopped.
73
+ *
74
+ * @param callback
75
+ * @returns EmitterSubscription
76
+ * @example ```js
77
+ * const subscription = HyperTrack.locate(location => {
78
+ * ...
79
+ * })
80
+ *
81
+ * // to unsubscribe
82
+ * subscription.remove()
83
+ * ```
53
84
  */
54
- getLocation(): Promise<Result<Location, LocationError>>;
85
+ static locate(callback: (location: Result<Location, HyperTrackError[]>) => void): EmitterSubscription;
55
86
  /**
56
- * Sets the name for the device
57
- * @param {string} name
87
+ * Sets the availability of the device for the Nearby search
88
+ *
89
+ * @param availability true when is available or false when unavailable
58
90
  */
59
- setName(name: string): void;
91
+ static setIsAvailable(isAvailable: boolean): Promise<void>;
60
92
  /**
61
- * Sets the metadata for the device
62
- * @param {Object} data - Metadata JSON
93
+ * Sets the tracking intent for the device
94
+ *
95
+ * @param {boolean} isTracking
63
96
  */
64
- setMetadata(data: Object): void;
97
+ static setIsTracking(isTracking: boolean): Promise<void>;
65
98
  /**
66
- * Adds a new geotag
99
+ * Sets the metadata for the device
67
100
  *
68
- * @param {Object} data - Geotad data JSON
69
- * @returns current location if success or LocationError if failure
101
+ * @param {Object} data - Metadata JSON
70
102
  */
71
- addGeotag(data: Object): Promise<Result<Location, LocationError>>;
103
+ static setMetadata(data: Object): Promise<void>;
72
104
  /**
73
- * Adds a new geotag with expected location
105
+ * Sets the name for the device
74
106
  *
75
- * @param {Object} data - Geotad data JSON
76
- * @param {Location} expectedLocation - Expected location
77
- * @returns location with deviation if success or LocationError if failure
107
+ * @param {string} name
78
108
  */
79
- addGeotag(data: Object, expectedLocation: Location): Promise<Result<LocationWithDeviation, LocationError>>;
109
+ static setName(name: string): Promise<void>;
80
110
  /**
81
111
  * Subscribe to tracking errors
82
112
  *
@@ -94,16 +124,16 @@ export default class HyperTrack {
94
124
  * subscription.remove()
95
125
  * ```
96
126
  */
97
- subscribeToErrors(listener: (errors: HyperTrackError[]) => void): import("react-native").EmitterSubscription;
127
+ static subscribeToErrors(listener: (errors: HyperTrackError[]) => void): EmitterSubscription;
98
128
  /**
99
- * Subscribe to tracking intent changes
129
+ * Subscribe to availability changes
100
130
  *
101
131
  * @param listener
102
132
  * @returns EmitterSubscription
103
133
  * @example
104
134
  * ```js
105
- * const subscription = HyperTrack.subscribeToTracking(isTracking => {
106
- * if (isTracking) {
135
+ * const subscription = HyperTrack.subscribeToIsAvailable(isAvailable => {
136
+ * if (isAvailable) {
107
137
  * // ... ready to go
108
138
  * }
109
139
  * })
@@ -112,16 +142,16 @@ export default class HyperTrack {
112
142
  * subscription.remove()
113
143
  * ```
114
144
  */
115
- subscribeToTracking(listener: (isTracking: boolean) => void): import("react-native").EmitterSubscription;
145
+ static subscribeToIsAvailable(listener: (isAvailable: boolean) => void): EmitterSubscription;
116
146
  /**
117
- * Subscribe to availability changes
147
+ * Subscribe to tracking intent changes
118
148
  *
119
149
  * @param listener
120
150
  * @returns EmitterSubscription
121
151
  * @example
122
152
  * ```js
123
- * const subscription = HyperTrack.subscribeToAvailability(isAvailable => {
124
- * if (isAvailable) {
153
+ * const subscription = HyperTrack.subscribeToIsTracking(isTracking => {
154
+ * if (isTracking) {
125
155
  * // ... ready to go
126
156
  * }
127
157
  * })
@@ -130,15 +160,37 @@ export default class HyperTrack {
130
160
  * subscription.remove()
131
161
  * ```
132
162
  */
133
- subscribeToAvailability(listener: (isAvailable: boolean) => void): import("react-native").EmitterSubscription;
163
+ static subscribeToIsTracking(listener: (isTracking: boolean) => void): EmitterSubscription;
164
+ /**
165
+ * Subscribe to location changes
166
+ *
167
+ * @param listener
168
+ * @returns EmitterSubscription
169
+ * @example
170
+ * ```js
171
+ * const subscription = HyperTrack.subscribeToLocation(location => {
172
+ * ...
173
+ * })
174
+ *
175
+ * // later, to stop listening
176
+ * subscription.remove()
177
+ * ```
178
+ */
179
+ static subscribeToLocation(listener: (location: Result<Location, LocationError>) => void): EmitterSubscription;
180
+ /** @ignore */
181
+ private static deserializeHyperTrackErrors;
182
+ /** @ignore */
183
+ private static deserializeLocateResponse;
184
+ /** @ignore */
185
+ private static deserializeLocationError;
134
186
  /** @ignore */
135
- private deserializeHyperTrackErrors;
187
+ private static deserializeLocationResponse;
136
188
  /** @ignore */
137
- private deserializeLocationResponse;
189
+ private static deserializeLocationWithDeviationResponse;
138
190
  /** @ignore */
139
- private deserializeLocationWithDeviationResponse;
191
+ private static deserializeMetadata;
140
192
  /** @ignore */
141
- private deserializeLocationError;
193
+ private static deserializeName;
142
194
  /** @ignore */
143
- private isLocation;
195
+ private static isLocation;
144
196
  }
@@ -1,20 +1,62 @@
1
1
  export declare enum HyperTrackError {
2
- gpsSignalLost = "gpsSignalLost",
3
- locationMocked = "locationMocked",
4
- locationPermissionsDenied = "locationPermissionsDenied",
5
- locationPermissionsInsufficientForBackground = "locationPermissionsInsufficientForBackground",
6
- locationPermissionsNotDetermined = "locationPermissionsNotDetermined",
7
- locationPermissionsReducedAccuracy = "locationPermissionsReducedAccuracy",
8
- locationPermissionsProvisional = "locationPermissionsProvisional",
9
- locationPermissionsRestricted = "locationPermissionsRestricted",
10
- locationServicesDisabled = "locationServicesDisabled",
11
- locationServicesUnavailable = "locationServicesUnavailable",
12
- motionActivityPermissionsNotDetermined = "motionActivityPermissionsNotDetermined",
13
- motionActivityPermissionsDenied = "motionActivityPermissionsDenied",
14
- motionActivityServicesDisabled = "motionActivityServicesDisabled",
15
- motionActivityServicesUnavailable = "motionActivityServicesUnavailable",
16
- motionActivityPermissionsRestricted = "motionActivityPermissionsRestricted",
17
- networkConnectionUnavailable = "networkConnectionUnavailable",
2
+ /**
3
+ * The SDK was remotely blocked from running.
4
+ */
5
+ blockedFromRunning = "blockedFromRunning",
6
+ /**
7
+ * The publishable key is invalid.
8
+ */
18
9
  invalidPublishableKey = "invalidPublishableKey",
19
- blockedFromRunning = "blockedFromRunning"
10
+ /**
11
+ * The user enabled mock location app while mocking locations is prohibited.
12
+ */
13
+ locationMocked = "location.mocked",
14
+ /**
15
+ * The user disabled location services systemwide.
16
+ */
17
+ locationServicesDisabled = "location.servicesDisabled",
18
+ /**
19
+ * [Android only] The device doesn't have location services.
20
+ */
21
+ locationServicesUnavailable = "location.servicesUnavailable",
22
+ /**
23
+ * GPS satellites are not in view.
24
+ */
25
+ locationSignalLost = "location.signalLost",
26
+ /**
27
+ * [Android only] The SDK wasn't able to start tracking because of the limitations imposed by the OS.
28
+ * The exempt from background execution conditions weren't met.
29
+ * {@link https://developer.android.com/guide/components/foreground-services#background-start-restriction-exemptions}
30
+ */
31
+ noExemptionFromBackgroundStartRestrictions = "noExemptionFromBackgroundStartRestrictions",
32
+ /**
33
+ * The user denied location permissions.
34
+ */
35
+ permissionsLocationDenied = "permissions.location.denied",
36
+ /**
37
+ * Can’t start tracking in background with When In Use location permissions.
38
+ * SDK will automatically start tracking when app will return to foreground.
39
+ */
40
+ permissionsLocationInsufficientForBackground = "permissions.location.insufficientForBackground",
41
+ /**
42
+ * [iOS only] The user has not chosen whether the app can use location services.
43
+ */
44
+ permissionsLocationNotDetermined = "permissions.location.notDetermined",
45
+ /**
46
+ * [iOS only] The app is in Provisional Always authorization state, which stops sending locations when app is in background.
47
+ */
48
+ permissionsLocationProvisional = "permissions.location.provisional",
49
+ /**
50
+ * The user didn't grant precise location permissions or downgraded permissions to imprecise.
51
+ */
52
+ permissionsLocationReducedAccuracy = "permissions.location.reducedAccuracy",
53
+ /**
54
+ * [iOS only] The app is not authorized to use location services.
55
+ */
56
+ permissionsLocationRestricted = "permissions.location.restricted",
57
+ /**
58
+ * [Android only] The user denied notification permissions needed to display a persistent notification
59
+ * needed for foreground location tracking.
60
+ */
61
+ permissionsNotificationsDenied = "permissions.notifications.denied"
20
62
  }
@@ -1,4 +1,4 @@
1
1
  export type HyperTrackErrorInternal = {
2
- type: "hyperTrackError";
2
+ type: 'error';
3
3
  value: string;
4
4
  };
@@ -0,0 +1,4 @@
1
+ export type Metadata = {
2
+ type: 'metadata';
3
+ value: Object;
4
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Device name
3
+ */
4
+ export type Name = {
5
+ type: 'name';
6
+ value: string;
7
+ };
@@ -6,5 +6,4 @@ export { NotRunning, Starting, } from './HyperTrack/data_types/internal/Location
6
6
  export { LocationError, Errors } from './HyperTrack/data_types/LocationError';
7
7
  export { LocationWithDeviation } from './HyperTrack/data_types/LocationWithDeviation';
8
8
  export { Location } from './HyperTrack/data_types/Location';
9
- export { SdkInitParams } from './HyperTrack/data_types/SdkInitParams';
10
9
  export { Result, Success, Failure } from './HyperTrack/data_types/Result';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypertrack-sdk-react-native",
3
- "version": "10.0.3",
3
+ "version": "11.0.0",
4
4
  "description": "React Native HyperTrack SDK is a wrapper around native iOS and Android SDKs that allows to integrate HyperTrack into React Native apps.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",