hypertrack-sdk-react-native 7.14.0 → 7.17.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 CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [7.17.0] - 2022-06-03
8
+ ### Changed
9
+ - Updated HyperTrack Android SDK to 6.1.1
10
+
11
+ ## [7.16.0] - 2022-05-03
12
+ ### Changed
13
+ - Updated HyperTrack Android SDK to [6.0.4](https://github.com/hypertrack/sdk-android/blob/master/CHANGELOG.md#604---2022-04-29)
14
+
15
+ ## [7.16.0] - 2022-05-03
16
+ ### Changed
17
+ - Updated HyperTrack Android SDK to [6.0.4](https://github.com/hypertrack/sdk-android/blob/master/CHANGELOG.md#604---2022-04-29)
18
+
19
+ ## [7.15.0] - 2022-04-29
20
+ ### Added
21
+ - Current location getter returns either the current location of the device or an outage reason for why current location is unavailable.
22
+
7
23
  ## [7.14.0] - 2022-03-24
8
24
  ### Changed
9
25
  - Updated HyperTrack Android SDK to [6.0.2](https://github.com/hypertrack/sdk-android/blob/master/CHANGELOG.md#602---2022-03-18)
@@ -236,6 +252,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
236
252
  ## [1.0.0] - 2019-06-07
237
253
  Initial release.
238
254
 
255
+ [7.15.0]: https://github.com/hypertrack/sdk-react-native/releases/tag/7.15.0
256
+ [7.14.0]: https://github.com/hypertrack/sdk-react-native/releases/tag/7.14.0
239
257
  [7.13.0]: https://github.com/hypertrack/sdk-react-native/releases/tag/7.13.0
240
258
  [7.12.1]: https://github.com/hypertrack/sdk-react-native/releases/tag/7.12.1
241
259
  [7.12.0]: https://github.com/hypertrack/sdk-react-native/releases/tag/7.12.0
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  ![GitHub](https://img.shields.io/github/license/hypertrack/sdk-react-native.svg)
4
4
  ![npm](https://img.shields.io/npm/v/hypertrack-sdk-react-native.svg)
5
- [![iOS SDK](https://img.shields.io/badge/iOS%20SDK-4.9.0-brightgreen.svg)](https://cocoapods.org/pods/HyperTrack)
6
- ![Android SDK](https://img.shields.io/badge/Android%20SDK-6.0.2-brightgreen.svg)
5
+ [![iOS SDK](https://img.shields.io/badge/iOS%20SDK-4.11.1-brightgreen.svg)](https://cocoapods.org/pods/HyperTrack)
6
+ ![Android SDK](https://img.shields.io/badge/Android%20SDK-6.1.1-brightgreen.svg)
7
7
 
8
8
  [HyperTrack](https://www.hypertrack.com) lets you add live location tracking to your mobile app. Live location is made available along with ongoing activity, tracking controls and tracking outage with reasons.
9
9
 
@@ -15,7 +15,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 30
15
15
  def DEFAULT_BUILD_TOOLS_VERSION = "30.0.2"
16
16
  def DEFAULT_MIN_SDK_VERSION = 21
17
17
  def DEFAULT_TARGET_SDK_VERSION = 30
18
- def DEFAULT_HYPERTRACK_SDK_VERSION = "6.0.2"
18
+ def DEFAULT_HYPERTRACK_SDK_VERSION = "6.1.1"
19
19
 
20
20
  def HYPERTRACK_SDK_VERSION = rootProject.hasProperty('hypertrackSdkVersion') ? rootProject.hypertrackSdkVersion : DEFAULT_HYPERTRACK_SDK_VERSION
21
21
 
@@ -12,27 +12,20 @@ import com.facebook.react.bridge.ReadableMap;
12
12
  import com.facebook.react.bridge.WritableMap;
13
13
  import com.facebook.react.module.annotations.ReactModule;
14
14
  import com.facebook.react.modules.core.DeviceEventManagerModule;
15
+ import com.hypertrack.sdk.AsyncResultReceiver;
15
16
  import com.hypertrack.sdk.GeotagResult;
16
17
  import com.hypertrack.sdk.HyperTrack;
18
+ import com.hypertrack.sdk.OutageReason;
19
+ import com.hypertrack.sdk.Result;
17
20
  import com.hypertrack.sdk.TrackingError;
18
21
  import com.hypertrack.sdk.TrackingStateObserver;
19
22
 
20
- import java.io.Serializable;
21
- import java.util.HashMap;
22
23
  import java.util.Locale;
23
- import java.util.Map;
24
24
 
25
25
 
26
26
  @ReactModule(name = HTSDKModule.NAME)
27
27
  public class HTSDKModule extends ReactContextBaseJavaModule {
28
28
 
29
- private static final String TAG = "HTSDKModule";
30
-
31
- public static final String NAME = "HyperTrack";
32
- public static final String LATITUDE = "latitude";
33
- public static final String LONGITUDE = "longitude";
34
- public static final String ACCURACY = "accuracy";
35
-
36
29
  public TrackingStateObserver.OnTrackingStateChangeListener trackingStateChangeListener;
37
30
  public HyperTrack sdkInstance;
38
31
 
@@ -56,7 +49,7 @@ public class HTSDKModule extends ReactContextBaseJavaModule {
56
49
  }
57
50
  promise.resolve(true);
58
51
  } catch (java.lang.Exception exception) {
59
- Log.e(TAG, "Hypertrack SDK initialization failed.", exception);
52
+ Log.e(TAG, "Hypertrack SDK initialization failed.", exception);
60
53
  String error = String.format(Locale.ENGLISH, "%d", RN_ERROR_INVALID_PUBLISHABLE_KEY);
61
54
  promise.reject(error, new Exception("Hypertrack SDK initialization failed."));
62
55
  }
@@ -213,6 +206,80 @@ public class HTSDKModule extends ReactContextBaseJavaModule {
213
206
  }
214
207
  }
215
208
 
209
+ @ReactMethod
210
+ public void getLocation(Promise promise) {
211
+ promise.resolve(locationResultToMap(sdkInstance.getLatestLocation()));
212
+ }
213
+
214
+ @ReactMethod
215
+ public void getCurrentLocation(final Promise promise) {
216
+ sdkInstance.getCurrentLocation(new AsyncResultReceiver<Location, OutageReason>() {
217
+ @Override
218
+ public void onResult(Result<Location, OutageReason> result) {
219
+ promise.resolve(locationResultToMap(result));
220
+ }
221
+ });
222
+ }
223
+
224
+ private WritableMap locationResultToMap(Result<Location, OutageReason> result) {
225
+ WritableMap resultMap = Arguments.createMap();
226
+ if (result.isSuccess()) {
227
+ Location location = result.getValue();
228
+ WritableMap locationMap = Arguments.createMap();
229
+ locationMap.putDouble(LATITUDE, location.getLatitude());
230
+ locationMap.putDouble(LONGITUDE, location.getLongitude());
231
+ resultMap.putMap(KEY_LOCATION, locationMap);
232
+ } else {
233
+ OutageReason outage = result.getError();
234
+ WritableMap errorMap = Arguments.createMap();
235
+ errorMap.putString(KEY_OUTAGE_CODE, getOutageName(outage));
236
+ resultMap.putMap(KEY_ERROR, errorMap);
237
+ }
238
+ return resultMap;
239
+ }
240
+
241
+ private String getOutageName(OutageReason outageReason) {
242
+ switch (outageReason) {
243
+ case MISSING_LOCATION_PERMISSION:
244
+ return OUTAGE_CODE_LOCATION_PERMISSIONS_DENIED;
245
+
246
+ case MISSING_ACTIVITY_PERMISSION:
247
+ return OUTAGE_CODE_MOTION_ACTIVITY_PERMISSIONS_DENIED;
248
+
249
+ case LOCATION_SERVICE_DISABLED:
250
+ return OUTAGE_CODE_LOCATION_SERVICES_DISABLED;
251
+
252
+ case NOT_TRACKING:
253
+ return OUTAGE_CODE_NOT_RUNNING;
254
+
255
+ case START_HAS_NOT_FINISHED:
256
+ return OUTAGE_CODE_STARTING;
257
+
258
+ case NO_GPS_SIGNAL:
259
+ case RESTART_REQUIRED:
260
+ default:
261
+ return OUTAGE_CODE_GPS_SIGNAL_LOST;
262
+ }
263
+ }
264
+
265
+ private static final String TAG = "HTSDKModule";
266
+
267
+ private static final String KEY_LOCATION = "location";
268
+ private static final String KEY_ERROR = "error";
269
+ private static final String KEY_OUTAGE_CODE = "code";
270
+
271
+ public static final String NAME = "HyperTrack";
272
+ public static final String LATITUDE = "latitude";
273
+ public static final String LONGITUDE = "longitude";
274
+ public static final String ACCURACY = "accuracy";
275
+
276
+ private static final String OUTAGE_CODE_LOCATION_PERMISSIONS_DENIED = "location_permissions_denied";
277
+ private static final String OUTAGE_CODE_LOCATION_SERVICES_DISABLED = "location_services_disabled";
278
+ private static final String OUTAGE_CODE_MOTION_ACTIVITY_PERMISSIONS_DENIED = "motion_activity_permissions_denied";
279
+ private static final String OUTAGE_CODE_NOT_RUNNING = "not_running";
280
+ private static final String OUTAGE_CODE_GPS_SIGNAL_LOST = "gps_signal_lost";
281
+ private static final String OUTAGE_CODE_STARTING = "starting";
282
+
216
283
  private static final int RN_ERROR_GENERAL = 0;
217
284
  private static final int RN_ERROR_INVALID_PUBLISHABLE_KEY = 1;
218
285
  private static final int RN_ERROR_AUTHORIZATION_FAILED = 2;
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
12
12
  s.source = { :git => 'https://github.com/hypertrack/sdk-react-native.git' }
13
13
  s.platform = :ios, '11.0'
14
14
  s.dependency 'React-Core'
15
- s.dependency 'HyperTrack/Objective-C', '4.9.0'
15
+ s.dependency 'HyperTrack/Objective-C', '4.11.1'
16
16
  s.source_files = "ios/*.{xcodeproj}", "ios/RNHyperTrack/*.{h,m}"
17
17
  s.cocoapods_version = '>= 1.10.0'
18
18
  end
@@ -153,6 +153,61 @@ RCT_EXPORT_METHOD(isTracking:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromis
153
153
  resolve([NSNumber numberWithBool:[self.hyperTrack isRunning]]);
154
154
  }
155
155
 
156
+ RCT_EXPORT_METHOD(getLocation:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
157
+ HTLocationResult *locationResult = self.hyperTrack.location;
158
+
159
+ switch (locationResult.error) {
160
+ case HTLocationErrorNoError:
161
+ resolve(@{ @"location": @{ @"latitude": [NSNumber numberWithDouble:locationResult.location.latitude], @"longitude": [NSNumber numberWithDouble:locationResult.location.longitude] } });
162
+ break;
163
+ case HTLocationErrorLocationPermissionsNotDetermined:
164
+ resolve(@{ @"error": @{ @"code": @"location_permissions_not_determined" } });
165
+ break;
166
+ case HTLocationErrorLocationPermissionsCantBeAskedInBackground:
167
+ resolve(@{ @"error": @{ @"code": @"location_permissions_cant_be_asked_in_background" } });
168
+ break;
169
+ case HTLocationErrorLocationPermissionsInsufficientForBackground:
170
+ resolve(@{ @"error": @{ @"code": @"location_permissions_insufficient_for_background" } });
171
+ break;
172
+ case HTLocationErrorLocationPermissionsRestricted:
173
+ resolve(@{ @"error": @{ @"code": @"location_permissions_restricted" } });
174
+ break;
175
+ case HTLocationErrorLocationPermissionsReducedAccuracy:
176
+ resolve(@{ @"error": @{ @"code": @"location_permissions_reduced_accuracy" } });
177
+ break;
178
+ case HTLocationErrorLocationPermissionsDenied:
179
+ resolve(@{ @"error": @{ @"code": @"location_permissions_denied" } });
180
+ break;
181
+ case HTLocationErrorLocationServicesDisabled:
182
+ resolve(@{ @"error": @{ @"code": @"location_services_disabled" } });
183
+ break;
184
+ case HTLocationErrorMotionActivityPermissionsNotDetermined:
185
+ resolve(@{ @"error": @{ @"code": @"motion_activity_permissions_not_determined" } });
186
+ break;
187
+ case HTLocationErrorMotionActivityPermissionsCantBeAskedInBackground:
188
+ resolve(@{ @"error": @{ @"code": @"motion_activity_permissions_cant_be_asked_in_background" } });
189
+ break;
190
+ case HTLocationErrorMotionActivityPermissionsDenied:
191
+ resolve(@{ @"error": @{ @"code": @"motion_activity_permissions_denied" } });
192
+ break;
193
+ case HTLocationErrorMotionActivityServicesDisabled:
194
+ resolve(@{ @"error": @{ @"code": @"motion_activity_services_disabled" } });
195
+ break;
196
+ case HTLocationErrorNotRunning:
197
+ resolve(@{ @"error": @{ @"code": @"not_running" } });
198
+ break;
199
+ case HTLocationErrorGpsSignalLost:
200
+ resolve(@{ @"error": @{ @"code": @"gps_signal_lost" } });
201
+ break;
202
+ case HTLocationErrorStarting:
203
+ resolve(@{ @"error": @{ @"code": @"starting" } });
204
+ break;
205
+ case HTLocationErrorLocationMocked:
206
+ resolve(@{ @"error": @{ @"code": @"location_mocked" } });
207
+ break;
208
+ }
209
+ }
210
+
156
211
  RCT_EXPORT_METHOD(getDeviceID:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
157
212
  resolve(self.hyperTrack.deviceID);
158
213
  }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RNHyperTrack.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -45,4 +45,53 @@ export const INVALID_ARGUMENTS = 3;
45
45
  * Interface for accessing adding geotag result.
46
46
  * @property {number} code - is one of {@link PLATFORM_NOT_SUPPORTED}, {@link LOCATION_NOT_AVAILABLE}, {@link LOCATION_MISMATCH}, {@link INVALID_ARGUMENTS}
47
47
  */
48
- export type GeotagError = { code: number }
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/HyperTrack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  import EventEmitter from './EventEmitter';
4
- import {Error, GeotagError} from './CriticalErrors';
4
+ import {Error, GeotagError, LocationError} from './CriticalErrors';
5
5
 
6
6
  const HyperTrack = require('react-native').NativeModules.HyperTrack;
7
7
 
@@ -43,6 +43,11 @@ class HyperTrackAPI {
43
43
  HyperTrack.stopTracking();
44
44
  }
45
45
 
46
+ /// The current location of the user or an outage reason.
47
+ getLocation(): Promise<LocationError|GeolocationCoordinates> {
48
+ return HyperTrack.getLocation();
49
+ }
50
+
46
51
  /**
47
52
  * Registers tracking state callbacks.
48
53
  * @param {Object} component - Instance of your component.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypertrack-sdk-react-native",
3
- "version": "7.14.0",
3
+ "version": "7.17.0",
4
4
  "description": "React Native module for a HyperTrack SDK",
5
5
  "main": "./js/index.js",
6
6
  "author": "HyperTrack <help@hypertrack.com> (https://hypertrack.com)",