From 5111c2dbe2274610738af2546e46df2c375d400d Mon Sep 17 00:00:00 2001 From: pavel-kuznetsov-hypertrack <78730314+pavel-kuznetsov-hypertrack@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:36:46 +0300 Subject: [PATCH] Add worker handle support (#109) --- CHANGELOG.md | 13 ++++++++ README.md | 2 +- docs/assets/search.js | 2 +- docs/classes/HyperTrack.html | 20 ++++++++--- docs/enums/HyperTrackError.html | 4 +-- docs/index.html | 4 +-- docs/modules.html | 4 +-- docs/types/Errors.html | 2 +- docs/types/Failure.html | 2 +- docs/types/Location.html | 2 +- docs/types/LocationError.html | 2 +- docs/types/LocationWithDeviation.html | 2 +- docs/types/NotRunning.html | 2 +- docs/types/OrderStatus.html | 2 +- docs/types/Result.html | 2 +- docs/types/Starting.html | 2 +- docs/types/Success.html | 2 +- .../android/gradle.properties | 2 +- .../package.json | 2 +- .../android/gradle.properties | 2 +- .../package.json | 2 +- .../android/gradle.properties | 2 +- .../package.json | 2 +- sdk/android/gradle.properties | 2 +- .../HyperTrackReactNativePlugin.kt | 10 ++++++ .../common/HyperTrackSdkWrapper.kt | 15 +++++++++ .../common/SdkMethod.kt | 2 ++ .../common/Serialization.kt | 21 ++++++++++-- sdk/ios/HyperTrackReactNativePlugin.m | 7 ++++ sdk/ios/HyperTrackReactNativePlugin.swift | 33 +++++++++++++++++-- sdk/ios/common/HyperTrackSDKWrapper.swift | 30 +++++++++++------ sdk/ios/common/SDKMethod.swift | 2 ++ sdk/ios/common/Serialization.swift | 26 ++++++++++++--- sdk/package.json | 2 +- sdk/src/HyperTrack/HyperTrack.ts | 30 +++++++++++++++++ .../data_types/internal/WorkerHandle.ts | 4 +++ 36 files changed, 216 insertions(+), 49 deletions(-) create mode 100644 sdk/src/HyperTrack/data_types/internal/WorkerHandle.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e16aacf..24037bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [13.4.0] - 2024-06-13 + +### Added + +- New `setWorkerHandle` and `getWorkerHandle` can be used to identify workers + - We observed our customers identify worker devices via `HyperTrack.metadata`, so we decided to make it a first class citizen in our API. + - If you previously used `metadata` to identify workers, we suggest using `workerHandle` for this purpose instead. + +### Changed + +- Updated HyperTrack SDK Android to [7.6.0](https://github.com/hypertrack/sdk-android/releases/tag/7.6.0) + ## [13.3.5] - 2024-06-05 ### Changed @@ -856,3 +868,4 @@ Initial release. [13.3.3]: https://github.com/hypertrack/sdk-react-native/releases/tag/13.3.3 [13.3.4]: https://github.com/hypertrack/sdk-react-native/releases/tag/13.3.4 [13.3.5]: https://github.com/hypertrack/sdk-react-native/releases/tag/13.3.5 +[13.4.0]: https://github.com/hypertrack/sdk-react-native/releases/tag/13.4.0 diff --git a/README.md b/README.md index 4b0f5a3..4e94a38 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![GitHub](https://img.shields.io/github/license/hypertrack/sdk-react-native?color=orange)](./LICENSE) [![npm](https://img.shields.io/npm/v/hypertrack-sdk-react-native.svg)](https://www.npmjs.com/package/hypertrack-sdk-react-native) [![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.6.0-brightgreen.svg)](https://github.com/hypertrack/sdk-ios) -[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.5.5-brightgreen.svg)](https://github.com/hypertrack/sdk-android) +[![Android SDK](https://img.shields.io/badge/Android%20SDK-7.6.0-brightgreen.svg)](https://github.com/hypertrack/sdk-android) [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. diff --git a/docs/assets/search.js b/docs/assets/search.js index b3de0eb..ac49ac9 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE61aWW/bRhD+L8qrqmgv2vJbiyRt0PRAkrYPgRHQ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QF2gOqZZb3B77DcvPLjNCyB0EDlv5viSQYo5qlYvysGX+F7ZA5c9plx0O3h63W2vu+V1+xecvSZgyxWF1Tx0u9R6zV2vueM164fbXkuALhUXvN7Xat/YfbNvDOgLoC8Y/Xv3dayot7T3qsAz57hXDOuPHaDvQFFIriqabTF8ZUlAWXKY+xeZoCRBug2r2GwbBekCs0pww6pWy9H+e2ACWBgzMJwaoCaNbMYul7fWwFHWNehozfVUq31o9gGBdIMgJNcZrXre7JQJuu07wBDoE8k1ytBQmZCNLgFKybVOZ6vaLxNX+2XAnAO1rLhibk18jYp7erCDYjS8le4FNxh0wL/h8pqkYbupxt0Hb7pdH7n79JihTTXg0kC9Ka7gkrQgbqsKJFZxiU3dC8C8eTUIrgi0t8ddEfhY3yY3aL7TgyhAyymu5QhLEdgkc5tmN2CTDDAO73DcLY4wbhMWgD0twCC4bsW1J2HwEW5CAebALVBx/UqYy+odI363YwSYBFWquMlHmuz3eABrYCKoCZwTuCmDgA3mguLmQtZ81wHVBorccGr5hJWKAPUguHrI2TWHAPQFRz/nVh0CwBYc7JxePQhAVXBUc2L9APgJjl8+sn4AwASb+W4zCBiWoK0119bdNuciPV4dCjCeBDeegAWGmQSzV3JTG5mh2ElQgZIbs8AKdYuX8EGIT0nzMRJUP9AzXCKOHu9AwLp5jNO6+XtZ//Wa4x5XjM3nJWAVlLDeNdrNasUjy9I+jT5Gj2FsB6l9EL1+efkfyvBlPl05AAA="; \ No newline at end of file diff --git a/docs/classes/HyperTrack.html b/docs/classes/HyperTrack.html index 56e7b40..d146027 100644 --- a/docs/classes/HyperTrack.html +++ b/docs/classes/HyperTrack.html @@ -1,4 +1,4 @@ -HyperTrack | HyperTrack React Native SDK API - v13.3.5

Constructors

constructor +HyperTrack | HyperTrack React Native SDK API - v13.4.0

Constructors

Properties

Methods

Returns Promise<Object>

Metadata JSON

  • Gets the name that is set for the device

    Returns Promise<string>

    Device name

    -
  • Requests one-time location update and returns the location once it is available, or error.

    +
  • A primary identifier that uniquely identifies the worker outside of HyperTrack. +Example: email, phone number, database id +It is usually obtained and set when the worker logs into the app. +Set it to an empty string "" when the worker logs out of the app to un-bind the device from the worker and +avoid unintentional tracking.

    +

    Returns Promise<string>

  • Requests one-time location update and returns the location once it is available, or error.

    Only one locate subscription can be active at a time. If you re-subscribe, the old EmitterSubscription will be automaticaly removed.

    This method will start location tracking if called, and will stop it when the location is received or @@ -64,7 +71,12 @@

    Parameters

    • isTracking: boolean

    Returns void

  • Sets the metadata for the device

    Parameters

    • data: Object

      Metadata JSON

    Returns void

  • Sets the name for the device

    -

    Parameters

    • name: string

    Returns void

  • Subscribe to tracking errors

    +

    Parameters

    • name: string

    Returns void

  • A primary identifier that uniquely identifies the worker outside of HyperTrack. +Example: email, phone number, database id +It is usually obtained and set when the worker logs into the app. +Set it to an empty string "" when the worker logs out of the app to un-bind the device from the worker and +avoid unintentional tracking.

    +

    Parameters

    • workerHandle: string

    Returns void

  • Subscribe to tracking errors

    Parameters

    • listener: ((errors) => void)

    Returns EmitterSubscription

    EmitterSubscription

    Example

    const subscription = HyperTrack.subscribeToErrors(errors => {
    errors.forEach(error => {
    // ... error
    })
    })

    // later, to stop listening
    subscription.remove()
    @@ -80,4 +92,4 @@

    Parameters

    Returns EmitterSubscription

    EmitterSubscription

    Example

    const subscription = HyperTrack.subscribeToLocation(location => {
    ...
    })

    // later, to stop listening
    subscription.remove()
    -
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/enums/HyperTrackError.html b/docs/enums/HyperTrackError.html index 13eb682..e7a14ff 100644 --- a/docs/enums/HyperTrackError.html +++ b/docs/enums/HyperTrackError.html @@ -1,4 +1,4 @@ -HyperTrackError | HyperTrack React Native SDK API - v13.3.5

Enumeration Members

blockedFromRunning +HyperTrackError | HyperTrack React Native SDK API - v13.4.0

Enumeration Members

permissionsLocationRestricted: "permissions.location.restricted"

[iOS only] The app is not authorized to use location services.

permissionsNotificationsDenied: "permissions.notifications.denied"

[Android only] The user denied notification permissions needed to display a persistent notification needed for foreground location tracking.

-
\ No newline at end of file +
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index c3b334b..45578c6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,2 +1,2 @@ -HyperTrack React Native SDK API - v13.3.5

HyperTrack React Native SDK API - v13.3.5

hypertrack-sdk-react-native

The main package for HyperTrack SDK React Native.

-
\ No newline at end of file +HyperTrack React Native SDK API - v13.4.0

HyperTrack React Native SDK API - v13.4.0

hypertrack-sdk-react-native

The main package for HyperTrack SDK React Native.

+
\ No newline at end of file diff --git a/docs/modules.html b/docs/modules.html index 298e9fd..c337122 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,4 +1,4 @@ -HyperTrack React Native SDK API - v13.3.5

HyperTrack React Native SDK API - v13.3.5

References

default +HyperTrack React Native SDK API - v13.4.0

HyperTrack React Native SDK API - v13.4.0

References

Enumerations

Classes

Type Aliases

Location @@ -11,4 +11,4 @@ Result NotRunning Starting -

References

Renames and re-exports HyperTrack
\ No newline at end of file +

References

Renames and re-exports HyperTrack
\ No newline at end of file diff --git a/docs/types/Errors.html b/docs/types/Errors.html index 23f3abc..19ff74e 100644 --- a/docs/types/Errors.html +++ b/docs/types/Errors.html @@ -1 +1 @@ -Errors | HyperTrack React Native SDK API - v13.3.5
Errors: {
    type: "errors";
    value: HyperTrackError[];
}

Type declaration

\ No newline at end of file +Errors | HyperTrack React Native SDK API - v13.4.0
Errors: {
    type: "errors";
    value: HyperTrackError[];
}

Type declaration

\ No newline at end of file diff --git a/docs/types/Failure.html b/docs/types/Failure.html index 646180f..b425753 100644 --- a/docs/types/Failure.html +++ b/docs/types/Failure.html @@ -1 +1 @@ -Failure | HyperTrack React Native SDK API - v13.3.5
Failure<F>: {
    type: "failure";
    value: F;
}

Type Parameters

  • F

Type declaration

  • type: "failure"
  • value: F
\ No newline at end of file +Failure | HyperTrack React Native SDK API - v13.4.0
Failure<F>: {
    type: "failure";
    value: F;
}

Type Parameters

  • F

Type declaration

  • type: "failure"
  • value: F
\ No newline at end of file diff --git a/docs/types/Location.html b/docs/types/Location.html index ca72e08..13187e4 100644 --- a/docs/types/Location.html +++ b/docs/types/Location.html @@ -1 +1 @@ -Location | HyperTrack React Native SDK API - v13.3.5
Location: {
    latitude: number;
    longitude: number;
}

Type declaration

  • latitude: number
  • longitude: number
\ No newline at end of file +Location | HyperTrack React Native SDK API - v13.4.0
Location: {
    latitude: number;
    longitude: number;
}

Type declaration

  • latitude: number
  • longitude: number
\ No newline at end of file diff --git a/docs/types/LocationError.html b/docs/types/LocationError.html index 6ccaa12..fd5fcd0 100644 --- a/docs/types/LocationError.html +++ b/docs/types/LocationError.html @@ -1 +1 @@ -LocationError | HyperTrack React Native SDK API - v13.3.5
LocationError: NotRunning | Starting | Errors
\ No newline at end of file +LocationError | HyperTrack React Native SDK API - v13.4.0
LocationError: NotRunning | Starting | Errors
\ No newline at end of file diff --git a/docs/types/LocationWithDeviation.html b/docs/types/LocationWithDeviation.html index d1593f3..30aa83e 100644 --- a/docs/types/LocationWithDeviation.html +++ b/docs/types/LocationWithDeviation.html @@ -1 +1 @@ -LocationWithDeviation | HyperTrack React Native SDK API - v13.3.5
LocationWithDeviation: {
    location: Location;
    deviation: number;
}

Type declaration

\ No newline at end of file +LocationWithDeviation | HyperTrack React Native SDK API - v13.4.0
LocationWithDeviation: {
    location: Location;
    deviation: number;
}

Type declaration

\ No newline at end of file diff --git a/docs/types/NotRunning.html b/docs/types/NotRunning.html index 4260618..a719c7c 100644 --- a/docs/types/NotRunning.html +++ b/docs/types/NotRunning.html @@ -1 +1 @@ -NotRunning | HyperTrack React Native SDK API - v13.3.5
NotRunning: {
    type: "notRunning";
}

Type declaration

  • type: "notRunning"
\ No newline at end of file +NotRunning | HyperTrack React Native SDK API - v13.4.0
NotRunning: {
    type: "notRunning";
}

Type declaration

  • type: "notRunning"
\ No newline at end of file diff --git a/docs/types/OrderStatus.html b/docs/types/OrderStatus.html index 3e20c44..98cfb6d 100644 --- a/docs/types/OrderStatus.html +++ b/docs/types/OrderStatus.html @@ -1 +1 @@ -OrderStatus | HyperTrack React Native SDK API - v13.3.5
OrderStatus: {
    type: "orderStatusClockIn";
} | {
    type: "orderStatusClockOut";
} | {
    type: "orderStatusCustom";
    value: string;
}

Type declaration

  • type: "orderStatusClockIn"

Type declaration

  • type: "orderStatusClockOut"

Type declaration

  • type: "orderStatusCustom"
  • value: string
\ No newline at end of file +OrderStatus | HyperTrack React Native SDK API - v13.4.0
OrderStatus: {
    type: "orderStatusClockIn";
} | {
    type: "orderStatusClockOut";
} | {
    type: "orderStatusCustom";
    value: string;
}

Type declaration

  • type: "orderStatusClockIn"

Type declaration

  • type: "orderStatusClockOut"

Type declaration

  • type: "orderStatusCustom"
  • value: string
\ No newline at end of file diff --git a/docs/types/Result.html b/docs/types/Result.html index 7b9152f..172bb32 100644 --- a/docs/types/Result.html +++ b/docs/types/Result.html @@ -1 +1 @@ -Result | HyperTrack React Native SDK API - v13.3.5
Result<S, F>: Success<S> | Failure<F>

Type Parameters

  • S

  • F

\ No newline at end of file +Result | HyperTrack React Native SDK API - v13.4.0
Result<S, F>: Success<S> | Failure<F>

Type Parameters

  • S

  • F

\ No newline at end of file diff --git a/docs/types/Starting.html b/docs/types/Starting.html index b15ce66..de00f43 100644 --- a/docs/types/Starting.html +++ b/docs/types/Starting.html @@ -1 +1 @@ -Starting | HyperTrack React Native SDK API - v13.3.5
Starting: {
    type: "starting";
}

Type declaration

  • type: "starting"
\ No newline at end of file +Starting | HyperTrack React Native SDK API - v13.4.0
Starting: {
    type: "starting";
}

Type declaration

  • type: "starting"
\ No newline at end of file diff --git a/docs/types/Success.html b/docs/types/Success.html index 7e8c52a..acd4f16 100644 --- a/docs/types/Success.html +++ b/docs/types/Success.html @@ -1 +1 @@ -Success | HyperTrack React Native SDK API - v13.3.5
Success<S>: {
    type: "success";
    value: S;
}

Type Parameters

  • S

Type declaration

  • type: "success"
  • value: S
\ No newline at end of file +Success | HyperTrack React Native SDK API - v13.4.0
Success<S>: {
    type: "success";
    value: S;
}

Type Parameters

  • S

Type declaration

  • type: "success"
  • value: S
\ No newline at end of file diff --git a/plugin_android_location_services_google/android/gradle.properties b/plugin_android_location_services_google/android/gradle.properties index 58c07b6..dc51a88 100644 --- a/plugin_android_location_services_google/android/gradle.properties +++ b/plugin_android_location_services_google/android/gradle.properties @@ -3,4 +3,4 @@ PluginAndroidLocationServicesGoogle_minSdkVersion=21 PluginAndroidLocationServicesGoogle_targetSdkVersion=31 PluginAndroidLocationServicesGoogle_compileSdkVersion=31 PluginAndroidLocationServicesGoogle_ndkversion=21.4.7075529 -PluginAndroidLocationServicesGoogle_HyperTrackSDKVersion=7.5.5 +PluginAndroidLocationServicesGoogle_HyperTrackSDKVersion=7.6.0 diff --git a/plugin_android_location_services_google/package.json b/plugin_android_location_services_google/package.json index 2f1c6da..6563096 100644 --- a/plugin_android_location_services_google/package.json +++ b/plugin_android_location_services_google/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-react-native-plugin-android-location-services-google", - "version": "13.3.5", + "version": "13.4.0", "description": "A wrapper around `Location Services Google` plugin for HyperTrack SDK Android that is used with `hypertrack-sdk-react-native`", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/plugin_android_location_services_google_19_0_1/android/gradle.properties b/plugin_android_location_services_google_19_0_1/android/gradle.properties index 75eaad4..a812cd5 100644 --- a/plugin_android_location_services_google_19_0_1/android/gradle.properties +++ b/plugin_android_location_services_google_19_0_1/android/gradle.properties @@ -3,4 +3,4 @@ PluginAndroidLocationServicesGoogle1901_minSdkVersion=21 PluginAndroidLocationServicesGoogle1901_targetSdkVersion=31 PluginAndroidLocationServicesGoogle1901_compileSdkVersion=31 PluginAndroidLocationServicesGoogle1901_ndkversion=21.4.7075529 -PluginAndroidLocationServicesGoogle1901_HyperTrackSDKVersion=7.5.5 +PluginAndroidLocationServicesGoogle1901_HyperTrackSDKVersion=7.6.0 diff --git a/plugin_android_location_services_google_19_0_1/package.json b/plugin_android_location_services_google_19_0_1/package.json index f5e6cc0..9e7c9fa 100644 --- a/plugin_android_location_services_google_19_0_1/package.json +++ b/plugin_android_location_services_google_19_0_1/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-react-native-plugin-android-location-services-google-19-0-1", - "version": "13.3.5", + "version": "13.4.0", "description": "A wrapper around `Location Services Google 19.0.1` plugin for HyperTrack SDK Android that is used with `hypertrack-sdk-react-native`", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/plugin_android_push_service_firebase/android/gradle.properties b/plugin_android_push_service_firebase/android/gradle.properties index b95a2b5..e38fd82 100644 --- a/plugin_android_push_service_firebase/android/gradle.properties +++ b/plugin_android_push_service_firebase/android/gradle.properties @@ -3,4 +3,4 @@ PluginAndroidPushServiceFirebase_minSdkVersion=21 PluginAndroidPushServiceFirebase_targetSdkVersion=31 PluginAndroidPushServiceFirebase_compileSdkVersion=31 PluginAndroidPushServiceFirebase_ndkversion=21.4.7075529 -PluginAndroidPushServiceFirebase_HyperTrackSDKVersion=7.5.5 +PluginAndroidPushServiceFirebase_HyperTrackSDKVersion=7.6.0 diff --git a/plugin_android_push_service_firebase/package.json b/plugin_android_push_service_firebase/package.json index 92ffbb8..66233f8 100644 --- a/plugin_android_push_service_firebase/package.json +++ b/plugin_android_push_service_firebase/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-react-native-plugin-android-push-service-firebase", - "version": "13.3.5", + "version": "13.4.0", "description": "A wrapper around `Push Service Firebase` plugin for HyperTrack SDK Android that is used with `hypertrack-sdk-react-native`", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/sdk/android/gradle.properties b/sdk/android/gradle.properties index e18dccd..a236d40 100644 --- a/sdk/android/gradle.properties +++ b/sdk/android/gradle.properties @@ -1,3 +1,3 @@ HyperTrackSdk_kotlinVersion=1.6.21 -HyperTrackSdk_HyperTrackSDKVersion=7.5.5 +HyperTrackSdk_HyperTrackSDKVersion=7.6.0 android.useAndroidX=true diff --git a/sdk/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt b/sdk/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt index 80ac5b1..a9e985e 100644 --- a/sdk/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +++ b/sdk/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt @@ -111,6 +111,11 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) : HyperTrackSdkWrapper.getName().toPromise(promise) } + @ReactMethod + fun getWorkerHandle(promise: Promise) { + HyperTrackSdkWrapper.getWorkerHandle().toPromise(promise) + } + @ReactMethod fun locate(promise: Promise) { locateSubscription?.cancel() @@ -146,6 +151,11 @@ class HyperTrackReactNativePlugin(reactContext: ReactApplicationContext?) : HyperTrackSdkWrapper.setName(args.toHashMap()) } + @ReactMethod + fun setWorkerHandle(args: ReadableMap) { + HyperTrackSdkWrapper.setWorkerHandle(args.toHashMap()) + } + private fun initListeners(): List { return mutableListOf().also { result -> HyperTrack.subscribeToErrors { diff --git a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt index 3bddd73..dabca4b 100644 --- a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +++ b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt @@ -9,6 +9,7 @@ import com.reactnativehypertracksdk.common.Serialization.deserializeIsAvailable import com.reactnativehypertracksdk.common.Serialization.deserializeIsTracking import com.reactnativehypertracksdk.common.Serialization.deserializeMetadata import com.reactnativehypertracksdk.common.Serialization.deserializeName +import com.reactnativehypertracksdk.common.Serialization.deserializeWorkerHandle import com.reactnativehypertracksdk.common.Serialization.serializeDeviceId import com.reactnativehypertracksdk.common.Serialization.serializeDynamicPublishableKey import com.reactnativehypertracksdk.common.Serialization.serializeErrors @@ -20,6 +21,7 @@ import com.reactnativehypertracksdk.common.Serialization.serializeLocationSucces import com.reactnativehypertracksdk.common.Serialization.serializeLocationWithDeviationSuccess import com.reactnativehypertracksdk.common.Serialization.serializeMetadata import com.reactnativehypertracksdk.common.Serialization.serializeName +import com.reactnativehypertracksdk.common.Serialization.serializeWorkerHandle typealias Serialized = Map @@ -137,6 +139,12 @@ internal object HyperTrackSdkWrapper { ) } + fun getWorkerHandle(): WrapperResult { + return Success( + serializeWorkerHandle(HyperTrack.workerHandle), + ) + } + fun setDynamicPublishableKey(args: Serialized): WrapperResult { return deserializeDynamicPublishableKey(args) .mapSuccess { publishableKey -> @@ -174,4 +182,11 @@ internal object HyperTrackSdkWrapper { HyperTrack.name = name } } + + fun setWorkerHandle(args: Serialized): WrapperResult { + return deserializeWorkerHandle(args) + .mapSuccess { workerHandle -> + HyperTrack.workerHandle = workerHandle + } + } } diff --git a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt index 3d6ddd9..a093598 100644 --- a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt +++ b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/SdkMethod.kt @@ -16,10 +16,12 @@ internal enum class SdkMethod { getLocation, getMetadata, getName, + getWorkerHandle, locate, setDynamicPublishableKey, setIsAvailable, setIsTracking, setMetadata, setName, + setWorkerHandle, } diff --git a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt index 66e7cf4..fea744e 100644 --- a/sdk/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +++ b/sdk/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt @@ -87,6 +87,15 @@ internal object Serialization { } } + fun deserializeWorkerHandle(map: Map): WrapperResult { + return parse(map) { + it.assertValue(key = KEY_TYPE, value = TYPE_WORKER_HANDLE) + it + .get(KEY_VALUE) + .getOrThrow() + } + } + fun serializeDeviceId(deviceId: String): Map { return mapOf( KEY_TYPE to TYPE_DEVICE_ID, @@ -206,6 +215,13 @@ internal object Serialization { ) } + fun serializeWorkerHandle(workerHandle: String): Map { + return mapOf( + KEY_TYPE to TYPE_WORKER_HANDLE, + KEY_VALUE to workerHandle, + ) + } + private fun deserializeLocation(map: Map): WrapperResult { return parse(map) { it.assertValue(key = KEY_TYPE, value = TYPE_LOCATION) @@ -397,10 +413,11 @@ internal object Serialization { private const val TYPE_ERROR = "error" private const val TYPE_IS_AVAILABLE = "isAvailable" private const val TYPE_IS_TRACKING = "isTracking" - private const val TYPE_METADATA = "metadata" - private const val TYPE_NAME = "name" private const val TYPE_LOCATION = "location" private const val TYPE_LOCATION_WITH_DEVIATION = "locationWithDeviation" + private const val TYPE_METADATA = "metadata" + private const val TYPE_NAME = "name" + private const val TYPE_WORKER_HANDLE = "workerHandle" private const val TYPE_LOCATION_ERROR_ERRORS = "errors" private const val TYPE_LOCATION_ERROR_NOT_RUNNING = "notRunning" diff --git a/sdk/ios/HyperTrackReactNativePlugin.m b/sdk/ios/HyperTrackReactNativePlugin.m index 952ac84..a9c43a7 100644 --- a/sdk/ios/HyperTrackReactNativePlugin.m +++ b/sdk/ios/HyperTrackReactNativePlugin.m @@ -37,6 +37,9 @@ @interface RCT_EXTERN_MODULE(HyperTrackReactNativePlugin, RCTEventEmitter) RCT_EXTERN_METHOD(getName:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(getWorkerHandle:(RCTPromiseResolveBlock)resolve + rejecter:(RCTPromiseRejectBlock)reject) + RCT_EXTERN_METHOD(locate:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) @@ -60,4 +63,8 @@ @interface RCT_EXTERN_MODULE(HyperTrackReactNativePlugin, RCTEventEmitter) resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +RCT_EXTERN_METHOD(setWorkerHandle:(NSDictionary *)args + resolver:(RCTPromiseResolveBlock)resolve + rejecter:(RCTPromiseRejectBlock)reject) + @end diff --git a/sdk/ios/HyperTrackReactNativePlugin.swift b/sdk/ios/HyperTrackReactNativePlugin.swift index 1429122..408d380 100644 --- a/sdk/ios/HyperTrackReactNativePlugin.swift +++ b/sdk/ios/HyperTrackReactNativePlugin.swift @@ -168,6 +168,18 @@ class HyperTrackReactNativePlugin: RCTEventEmitter { ) } + @objc func getWorkerHandle( + _ resolve: RCTPromiseResolveBlock, + rejecter reject: RCTPromiseRejectBlock + ) { + sendAsPromise( + hypertrack_sdk_react_native.getWorkerHandle(), + method: .getWorkerHandle, + resolve, + reject + ) + } + @objc func locate( _ resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock @@ -216,6 +228,21 @@ class HyperTrackReactNativePlugin: RCTEventEmitter { ) } + @objc func setIsTracking( + _ args: NSDictionary, + resolver resolve: RCTPromiseResolveBlock, + rejecter reject: RCTPromiseRejectBlock + ) { + sendAsPromise( + hypertrack_sdk_react_native.setIsTracking( + args as! [String: Any] + ), + method: .setIsTracking, + resolve, + reject + ) + } + @objc func setMetadata( _ args: NSDictionary, resolver resolve: RCTPromiseResolveBlock, @@ -244,16 +271,16 @@ class HyperTrackReactNativePlugin: RCTEventEmitter { ) } - @objc func setIsTracking( + @objc func setWorkerHandle( _ args: NSDictionary, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock ) { sendAsPromise( - hypertrack_sdk_react_native.setIsTracking( + hypertrack_sdk_react_native.setWorkerHandle( args as! [String: Any] ), - method: .setIsTracking, + method: .setWorkerHandle, resolve, reject ) diff --git a/sdk/ios/common/HyperTrackSDKWrapper.swift b/sdk/ios/common/HyperTrackSDKWrapper.swift index 27367a2..0184eb2 100644 --- a/sdk/ios/common/HyperTrackSDKWrapper.swift +++ b/sdk/ios/common/HyperTrackSDKWrapper.swift @@ -68,20 +68,28 @@ func getErrors() -> Result { .success(.array(serializeErrors(HyperTrack.errors))) } -func getMetadata() -> Result { - .success(.dict(serializeMetadata(HyperTrack.metadata))) +func getIsAvailable() -> Result { + .success(.dict(serializeIsAvailable(HyperTrack.isAvailable))) } -func getName() -> Result { - .success(.dict(serializeName(HyperTrack.name))) +func getIsTracking() -> Result { + .success(.dict(serializeIsTracking(HyperTrack.isTracking))) } func getLocation() -> Result { .success(.dict(serializeLocationResult(HyperTrack.location))) } -func getIsAvailable() -> Result { - .success(.dict(serializeIsAvailable(HyperTrack.isAvailable))) +func getMetadata() -> Result { + .success(.dict(serializeMetadata(HyperTrack.metadata))) +} + +func getName() -> Result { + .success(.dict(serializeName(HyperTrack.name))) +} + +func getWorkerHandle() -> Result { + .success(.dict(serializeWorkerHandle(HyperTrack.workerHandle))) } func setDynamicPublishableKey(_ args: [String: Any]) -> Result { @@ -98,10 +106,6 @@ func setIsAvailable(_ args: [String: Any]) -> Result Result { - .success(.dict(serializeIsTracking(HyperTrack.isTracking))) -} - func setIsTracking(_ args: [String: Any]) -> Result { deserializeIsTracking(args).flatMap { (isTracking: Bool) in HyperTrack.isTracking = isTracking @@ -126,6 +130,12 @@ func setName(_ args: [String: Any]) -> Result { } } +func setWorkerHandle(_ args: [String: Any]) -> Result { + deserializeWorkerHandle(args).flatMap { workerHandle in + .success(asVoid(HyperTrack.workerHandle = workerHandle)) + } +} + func asVoid(_: Void) -> SuccessResult { .void } diff --git a/sdk/ios/common/SDKMethod.swift b/sdk/ios/common/SDKMethod.swift index e7c0cd4..0de6f4e 100644 --- a/sdk/ios/common/SDKMethod.swift +++ b/sdk/ios/common/SDKMethod.swift @@ -8,10 +8,12 @@ enum SDKMethod: String { case getLocation case getMetadata case getName + case getWorkerHandle case locate case setDynamicPublishableKey case setIsAvailable case setIsTracking case setMetadata case setName + case setWorkerHandle } diff --git a/sdk/ios/common/Serialization.swift b/sdk/ios/common/Serialization.swift index 277a805..d1e4f92 100644 --- a/sdk/ios/common/Serialization.swift +++ b/sdk/ios/common/Serialization.swift @@ -13,6 +13,7 @@ private let typeLocation = "location" private let typeMetadata = "metadata" private let typeName = "name" private let typeSuccess = "success" +private let typeWorkerHandle = "workerHandle" func deserializeDynamicPublishableKey( _ args: [String: Any] @@ -170,6 +171,16 @@ func deserializeOrderStatus(_ data: [String: Any]) -> Result Result { + if data[keyType] as? String != typeWorkerHandle { + return .failure(.fatalError(getParseError(data, key: keyType))) + } + guard let value = data[keyValue] as? String else { + return .failure(.fatalError(getParseError(data, key: keyValue))) + } + return .success(value) +} + func serializeDeviceID(_ deviceID: String) -> [String: Any] { return [ keyType: "deviceID", @@ -226,6 +237,12 @@ func serializeError(_ error: HyperTrack.Error) -> [String: Any] { ] } +func serializeErrors(_ errors: Set) -> [[String: Any]] { + return errors.map { error in + serializeError(error) + } +} + func serializeIsAvailable(_ isAvailable: Bool) -> [String: Any] { return [ keyType: typeIsAvailable, @@ -341,10 +358,11 @@ func serializeName(_ name: String) -> [String: Any] { ] } -func serializeErrors(_ errors: Set) -> [[String: Any]] { - return errors.map { error in - serializeError(error) - } +func serializeWorkerHandle(_ workerHandle: String) -> [String: Any] { + return [ + keyType: typeWorkerHandle, + keyValue: workerHandle, + ] } private func toMap(_ object: HyperTrack.JSON.Object) -> [String: Any] { diff --git a/sdk/package.json b/sdk/package.json index 97effb0..97b5d09 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-react-native", - "version": "13.3.5", + "version": "13.4.0", "description": "React Native HyperTrack SDK is a wrapper around native iOS and Android SDKs that allows to integrate HyperTrack into React Native apps.", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/sdk/src/HyperTrack/HyperTrack.ts b/sdk/src/HyperTrack/HyperTrack.ts index 674d477..9c511d2 100644 --- a/sdk/src/HyperTrack/HyperTrack.ts +++ b/sdk/src/HyperTrack/HyperTrack.ts @@ -22,6 +22,7 @@ import type { Metadata } from './data_types/internal/Metadata'; import type { DynamicPublishableKey } from './data_types/internal/DynamicPublishableKey'; import type { OrderStatus } from './data_types/OrderStatus'; import type { OrderHandle } from './data_types/internal/OrderHandle'; +import type { WorkerHandle } from './data_types/internal/WorkerHandle'; const EVENT_ERRORS = 'errors'; const EVENT_IS_AVAILABLE = 'isAvailable'; @@ -292,6 +293,19 @@ export default class HyperTrack { }); } + /** + * A primary identifier that uniquely identifies the worker outside of HyperTrack. + * Example: email, phone number, database id + * It is usually obtained and set when the worker logs into the app. + * Set it to an empty string "" when the worker logs out of the app to un-bind the device from the worker and + * avoid unintentional tracking. + */ + static async getWorkerHandle(): Promise { + return HyperTrackSdk.getWorkerHandle().then( + (workerHandle: WorkerHandle) => workerHandle.value + ); + } + /** * Requests one-time location update and returns the location once it is available, or error. * @@ -383,6 +397,22 @@ export default class HyperTrack { } as Name); } + /** + * A primary identifier that uniquely identifies the worker outside of HyperTrack. + * Example: email, phone number, database id + * It is usually obtained and set when the worker logs into the app. + * Set it to an empty string "" when the worker logs out of the app to un-bind the device from the worker and + * avoid unintentional tracking. + * + * @param {string} workerHandle + */ + static setWorkerHandle(workerHandle: string) { + HyperTrackSdk.setWorkerHandle({ + type: 'workerHandle', + value: workerHandle, + } as WorkerHandle); + } + /** * Subscribe to tracking errors * diff --git a/sdk/src/HyperTrack/data_types/internal/WorkerHandle.ts b/sdk/src/HyperTrack/data_types/internal/WorkerHandle.ts new file mode 100644 index 0000000..4cfa372 --- /dev/null +++ b/sdk/src/HyperTrack/data_types/internal/WorkerHandle.ts @@ -0,0 +1,4 @@ +export type WorkerHandle = { + type: 'workerHandle'; + value: string; +};