diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c51db..1b04769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.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 iOS to [5.6.0](https://github.com/hypertrack/sdk-ios/releases/tag/5.6.0) +- Updated HyperTrack SDK Android to [7.6.0](https://github.com/hypertrack/sdk-android/releases/tag/7.6.0) + ## [3.3.1] - 2024-05-24 ### Changed @@ -215,3 +228,4 @@ We are excited to announce the release of HyperTrack Ionic Capacitor SDK 2.0.0, [3.2.2]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.2.2 [3.3.0]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.3.0 [3.3.1]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.3.1 +[3.4.0]: https://github.com/hypertrack/sdk-ionic-capacitor/releases/tag/3.4.0 diff --git a/HypertrackSdkIonicCapacitor.podspec b/HypertrackSdkIonicCapacitor.podspec index 8ef81c2..fcfbc34 100644 --- a/HypertrackSdkIonicCapacitor.podspec +++ b/HypertrackSdkIonicCapacitor.podspec @@ -14,5 +14,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '12.0' s.dependency 'Capacitor' s.swift_version = '5.1' - s.dependency 'HyperTrack','5.5.4' + s.dependency 'HyperTrack','5.6.0' end diff --git a/README.md b/README.md index 0ac7e05..cf1601b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![GitHub](https://img.shields.io/github/license/hypertrack/sdk-ionic-capacitor.svg?color=orange)](./LICENSE) [![npm](https://img.shields.io/npm/v/hypertrack-sdk-ionic-capacitor.svg)](https://www.npmjs.com/package/hypertrack-sdk-ionic-capacitor) -[![iOS SDK](https://img.shields.io/badge/iOS%20SDK-5.5.4-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) +[![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.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/android/build.gradle b/android/build.gradle index 8e18c33..767803e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,7 +7,7 @@ ext { buildscript { ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '1.9.10' - ext.hypertrack_sdk_version = "7.5.5" + ext.hypertrack_sdk_version = "7.6.0" ext.firebase_messaging_version = "23.1.1" repositories { diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt index 15ecab5..dd269d9 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/HyperTrackCapacitorPlugin.kt @@ -62,6 +62,11 @@ class HyperTrackCapacitorPlugin : Plugin() { invokeSdkMethod(SdkMethod.getName, call).toPluginCall(call) } + @PluginMethod + fun getWorkerHandle(call: PluginCall) { + invokeSdkMethod(SdkMethod.getWorkerHandle, call).toPluginCall(call) + } + @PluginMethod fun setIsAvailable(call: PluginCall) { invokeSdkMethod(SdkMethod.setIsAvailable, call).toPluginCall(call) @@ -82,6 +87,11 @@ class HyperTrackCapacitorPlugin : Plugin() { invokeSdkMethod(SdkMethod.setName, call).toPluginCall(call) } + @PluginMethod + fun setWorkerHandle(call: PluginCall) { + invokeSdkMethod(SdkMethod.setWorkerHandle, call).toPluginCall(call) + } + @PluginMethod fun onSubscribedToErrors(call: PluginCall) { sendErrorsEvent(HyperTrack.errors) @@ -211,6 +221,10 @@ class HyperTrackCapacitorPlugin : Plugin() { HyperTrackSdkWrapper.getName() } + SdkMethod.getWorkerHandle -> { + HyperTrackSdkWrapper.getWorkerHandle() + } + SdkMethod.locate -> { throw NotImplementedError("Locate is implemented in different way") } @@ -242,6 +256,12 @@ class HyperTrackCapacitorPlugin : Plugin() { HyperTrackSdkWrapper.setName(args) } } + + SdkMethod.setWorkerHandle -> { + withArgs, Unit>(argsJson) { args -> + HyperTrackSdkWrapper.setWorkerHandle(args) + } + } } } diff --git a/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt index 1ab1239..1d8281a 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/common/HyperTrackSdkWrapper.kt @@ -9,6 +9,7 @@ import com.hypertrack.sdk.capacitor.common.Serialization.deserializeIsAvailable import com.hypertrack.sdk.capacitor.common.Serialization.deserializeIsTracking import com.hypertrack.sdk.capacitor.common.Serialization.deserializeMetadata import com.hypertrack.sdk.capacitor.common.Serialization.deserializeName +import com.hypertrack.sdk.capacitor.common.Serialization.deserializeWorkerHandle import com.hypertrack.sdk.capacitor.common.Serialization.serializeDeviceId import com.hypertrack.sdk.capacitor.common.Serialization.serializeDynamicPublishableKey import com.hypertrack.sdk.capacitor.common.Serialization.serializeErrors @@ -20,6 +21,7 @@ import com.hypertrack.sdk.capacitor.common.Serialization.serializeLocationSucces import com.hypertrack.sdk.capacitor.common.Serialization.serializeLocationWithDeviationSuccess import com.hypertrack.sdk.capacitor.common.Serialization.serializeMetadata import com.hypertrack.sdk.capacitor.common.Serialization.serializeName +import com.hypertrack.sdk.capacitor.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/android/src/main/java/com/hypertrack/sdk/capacitor/common/SdkMethod.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/SdkMethod.kt index b1146d3..d78b384 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/SdkMethod.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/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/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt b/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt index bcbde92..2dfc8dd 100644 --- a/android/src/main/java/com/hypertrack/sdk/capacitor/common/Serialization.kt +++ b/android/src/main/java/com/hypertrack/sdk/capacitor/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/docs/assets/search.js b/docs/assets/search.js index 2b43ed4..27857d4 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62aWXPbRhKA/wv9ytCcCyT1li3Hu65Nsik7u/vgUrkgApJQBgEVACpJqfTfM4OzG+zGIfBJItAX+uvpmQHmZZWlf+Srm68vq+9REqxuhNyvV4l/Clc3q3/99RRmv2f+8ftqvTpnsb10jP08D/P33a3NY3GK7f36jpVZva5ba1upW3NxevSL8Mv5Lj9m0VMRpcmY2XekSuepyIMfovyHpyx6tmL21pOfhUmBQ++ikVvdPZwfBP8M08J/GA0CSoKnnOXtISw+hM/RMfwUjPrDsgs8/pRlaZZP8ddKLvD2Kf/x2Y9i/y4Op7jE4ov8lhJRMk6yL73A68+uMqeUMJZd4PGXsPADv/CneASyCzz+6v6b4K2We6unapBP7AUL/OTzavRCfJHfyTXal17gdXLF5FepmHxixeSLKyavJoS78Pd0Yo+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lfUMPNIF/w+U1ScPmVJCbfu7aYyu5+3aaoVNB4NFAP5FcQ0nSgpjNFEis4hKbuvdvef1mDvROkAuPywU4bdAkN6gPGoAHAG1Ncn2NsBSBUz73aXYHTvkA42A8SK79EcZtwgJwKAfkDDQIxQ1PwuATPEUDzIFuobjxSpjLqiMvfnvkBZgEZBTX+UiT3SEVYA3OzFzlAmsJPFVyCVuBvqC4vtC80AbVBtLk8Wp5b+mkwdgwnFrOrg8EbOUcnJxbIQjAQXAccnqmFyDrgst6fjnXC5BewT5we/YEcAGDUHGDsD1VXaSXKzEBmongmgmwwOUcdErB9RVkhsw9AC+4pgisUBOyACkRIym5WAQY0CY8FmDz4RRULHBquCxebKTA06p6w6TrDZLW9VKivu5xdVx/CgOhgOrXprZSL0w8sp7tvu8pegpj2zPtlu/29fVvV3I/EP03AAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62aW3OjVhKA/4vmVdHoXGX5LVuT2Uxtkk3NZDcPU64pLLBNWQIXIE9SLv/3nMO1G3UjMHqyBX2jv+7mAOdlkaXf88X115fFY5yEi2shr5aLJDhEi+vFz38/RdkfWbB7XCwXx2zvDu32QZ5H+fvu1OqhOOzd+fqMk1m8Lltra6lbc/t0FxTRl+NtvsvipyJOk3Nm35EqnaciD3+I8x+esvjZiblTT0EWJQUOvYtGrnV3cUEY/jtKi+D+bBBQElzlJG/3UfEheo530afwrD8sO8PjT1mWZvkYf63kDG+f8h+fg3gf3O6jMS6x+Cy/pUScnCfZl57h9RdfmWNKGMvO8PhrVARhUARjPALZGR5/8/+N8FbLzfD0Z5o9RtnPQRKOK56e/Fs9V+Nl5BSa4Sef1h0n4rP8ju6OvvQMr6NrNb9IreYjazWfXav5xFo9lX+z5+omeBv9kY6c65TGBbxPqmRO7SJxjK9sRusCUYy+D9A6EyIwQrYB7NIkL7Ljrkizs46x7ASH1EKwLKTWZZQcD9BheXZ4QWhbo7durD5G4ccsPXw+JgnkyNt9R2qdu6gqaj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YblcgJ0QTXLDehMEiALMGcUNGsJSDHYg3aXZLdiBBIyDflBcOxLGXcJCsGEIGARjTXHtSRh8gjt8gDl44+T6lTCXVdtxgnY7DjAJyChu8pEmuw00wBqYCIqrXGAtgTteCNhgLihuLjQv20G1gTRZXi3vLb006A3DqeXs+kIA1oJjnXMrDAFiFhzanF4pCMBQcAzz07WCALQERysfWC0APIJNWLuvBmQaNLHmmrjdMV6kpytBAYaR4IYRsMAxA5NWcHMJmSHZgcIR3FAFVqgbugQpkWdScrKIMKD0LAuy+SgM9IBTw2Xx5EEOXK2qH9h0/YCmbb0UqY9brpLrz3ygJED9602tXS9sLFnT7rnzKX6K9m7mukfOm9fXfwDX2W65zTkAAA=="; \ No newline at end of file diff --git a/docs/classes/HyperTrack.html b/docs/classes/HyperTrack.html index 6fc5f0b..c73c29f 100644 --- a/docs/classes/HyperTrack.html +++ b/docs/classes/HyperTrack.html @@ -1,4 +1,4 @@ -HyperTrack | HyperTrack Ionic Capacitor SDK API - v3.3.1

Constructors

constructor +HyperTrack | HyperTrack Ionic Capacitor SDK API - v3.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 Subscription will be automaticaly removed.

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

    Parameters

    • isTracking: boolean

    Returns Promise<void>

  • Sets the metadata for the device

    Parameters

    • data: Object

      Metadata JSON

    Returns Promise<void>

  • Sets the name for the device

    -

    Parameters

    • name: string

    Returns Promise<void>

  • Subscribe to tracking errors

    +

    Parameters

    • name: string

    Returns Promise<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 Subscription

    Subscription

    Example

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

    // later, to stop listening
    subscription.remove()
    @@ -79,4 +91,4 @@

    Parameters

    Returns Subscription

    Subscription

    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 3496ff4..cff5ab6 100644 --- a/docs/enums/HyperTrackError.html +++ b/docs/enums/HyperTrackError.html @@ -1,4 +1,4 @@ -HyperTrackError | HyperTrack Ionic Capacitor SDK API - v3.3.1

Enumeration Members

blockedFromRunning +HyperTrackError | HyperTrack Ionic Capacitor SDK API - v3.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 4c7e11a..afe7465 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,4 @@ -HyperTrack Ionic Capacitor SDK API - v3.3.1

HyperTrack Ionic Capacitor SDK API - v3.3.1

References

default +HyperTrack Ionic Capacitor SDK API - v3.4.0

HyperTrack Ionic Capacitor SDK API - v3.4.0

References

Enumerations

Classes

Interfaces

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/interfaces/Subscription.html b/docs/interfaces/Subscription.html index 28b73e8..6185c26 100644 --- a/docs/interfaces/Subscription.html +++ b/docs/interfaces/Subscription.html @@ -1,2 +1,2 @@ -Subscription | HyperTrack Ionic Capacitor SDK API - v3.3.1
interface Subscription {
    remove: (() => Promise<Object>);
}

Properties

Properties

remove: (() => Promise<Object>)

Type declaration

    • (): Promise<Object>
    • Returns Promise<Object>

\ No newline at end of file +Subscription | HyperTrack Ionic Capacitor SDK API - v3.4.0
interface Subscription {
    remove: (() => Promise<Object>);
}

Properties

Properties

remove: (() => Promise<Object>)

Type declaration

    • (): Promise<Object>
    • Returns Promise<Object>

\ No newline at end of file diff --git a/docs/types/Errors.html b/docs/types/Errors.html index b23291b..f144cca 100644 --- a/docs/types/Errors.html +++ b/docs/types/Errors.html @@ -1 +1 @@ -Errors | HyperTrack Ionic Capacitor SDK API - v3.3.1
Errors: {
    type: "errors";
    value: HyperTrackError[];
}

Type declaration

\ No newline at end of file +Errors | HyperTrack Ionic Capacitor SDK API - v3.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 1f150ea..a47d110 100644 --- a/docs/types/Failure.html +++ b/docs/types/Failure.html @@ -1 +1 @@ -Failure | HyperTrack Ionic Capacitor SDK API - v3.3.1
Failure<F>: {
    type: "failure";
    value: F;
}

Type Parameters

  • F

Type declaration

  • type: "failure"
  • value: F
\ No newline at end of file +Failure | HyperTrack Ionic Capacitor SDK API - v3.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 97b480a..d32f0d9 100644 --- a/docs/types/Location.html +++ b/docs/types/Location.html @@ -1 +1 @@ -Location | HyperTrack Ionic Capacitor SDK API - v3.3.1
Location: {
    latitude: number;
    longitude: number;
}

Type declaration

  • latitude: number
  • longitude: number
\ No newline at end of file +Location | HyperTrack Ionic Capacitor SDK API - v3.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 46ac673..cd72408 100644 --- a/docs/types/LocationError.html +++ b/docs/types/LocationError.html @@ -1 +1 @@ -LocationError | HyperTrack Ionic Capacitor SDK API - v3.3.1
\ No newline at end of file +LocationError | HyperTrack Ionic Capacitor SDK API - v3.4.0
\ No newline at end of file diff --git a/docs/types/LocationWithDeviation.html b/docs/types/LocationWithDeviation.html index d0cd93e..d9adcf5 100644 --- a/docs/types/LocationWithDeviation.html +++ b/docs/types/LocationWithDeviation.html @@ -1 +1 @@ -LocationWithDeviation | HyperTrack Ionic Capacitor SDK API - v3.3.1
LocationWithDeviation: {
    location: Location;
    deviation: number;
}

Type declaration

\ No newline at end of file +LocationWithDeviation | HyperTrack Ionic Capacitor SDK API - v3.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 72d0bc4..b6319da 100644 --- a/docs/types/NotRunning.html +++ b/docs/types/NotRunning.html @@ -1 +1 @@ -NotRunning | HyperTrack Ionic Capacitor SDK API - v3.3.1
NotRunning: {
    type: "notRunning";
}

Type declaration

  • type: "notRunning"
\ No newline at end of file +NotRunning | HyperTrack Ionic Capacitor SDK API - v3.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 f5e1a67..f17c209 100644 --- a/docs/types/OrderStatus.html +++ b/docs/types/OrderStatus.html @@ -1 +1 @@ -OrderStatus | HyperTrack Ionic Capacitor SDK API - v3.3.1
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 Ionic Capacitor SDK API - v3.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 457d8e0..7df46b5 100644 --- a/docs/types/Result.html +++ b/docs/types/Result.html @@ -1 +1 @@ -Result | HyperTrack Ionic Capacitor SDK API - v3.3.1
\ No newline at end of file +Result | HyperTrack Ionic Capacitor SDK API - v3.4.0
\ No newline at end of file diff --git a/docs/types/Starting.html b/docs/types/Starting.html index df5afd7..78d13af 100644 --- a/docs/types/Starting.html +++ b/docs/types/Starting.html @@ -1 +1 @@ -Starting | HyperTrack Ionic Capacitor SDK API - v3.3.1
Starting: {
    type: "starting";
}

Type declaration

  • type: "starting"
\ No newline at end of file +Starting | HyperTrack Ionic Capacitor SDK API - v3.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 8895c34..06e2451 100644 --- a/docs/types/Success.html +++ b/docs/types/Success.html @@ -1 +1 @@ -Success | HyperTrack Ionic Capacitor SDK API - v3.3.1
Success<S>: {
    type: "success";
    value: S;
}

Type Parameters

  • S

Type declaration

  • type: "success"
  • value: S
\ No newline at end of file +Success | HyperTrack Ionic Capacitor SDK API - v3.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/ios/Plugin/HyperTrackCapacitorPlugin.m b/ios/Plugin/HyperTrackCapacitorPlugin.m index 9a134fd..47ac52a 100644 --- a/ios/Plugin/HyperTrackCapacitorPlugin.m +++ b/ios/Plugin/HyperTrackCapacitorPlugin.m @@ -12,13 +12,15 @@ CAP_PLUGIN_METHOD(getLocation, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(getMetadata, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(getName, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setIsAvailable, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setIsTracking, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setMetadata, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setName, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(getWorkerHandle, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(onSubscribedToErrors, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(onSubscribedToIsAvailable, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(onSubscribedToIsTracking, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(onSubscribedToLocate, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(onSubscribedToLocation, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(setIsAvailable, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(setIsTracking, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(setMetadata, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(setName, CAPPluginReturnPromise); + CAP_PLUGIN_METHOD(setWorkerHandle, CAPPluginReturnPromise); ) diff --git a/ios/Plugin/HyperTrackCapacitorPlugin.swift b/ios/Plugin/HyperTrackCapacitorPlugin.swift index 2323ed3..649c17c 100644 --- a/ios/Plugin/HyperTrackCapacitorPlugin.swift +++ b/ios/Plugin/HyperTrackCapacitorPlugin.swift @@ -20,7 +20,7 @@ public class HyperTrackCapacitorPlugin: CAPPlugin { private var locationSubscription: HyperTrack.Cancellable! private var locateSubscription: HyperTrack.Cancellable? = nil - + override public func load() { initListeners() } @@ -100,6 +100,14 @@ public class HyperTrackCapacitorPlugin: CAPPlugin { ) } + @objc func getWorkerHandle(_ call: CAPPluginCall) { + sendAsPromise( + HypertrackSdkIonicCapacitor.getWorkerHandle(), + method: .getWorkerHandle, + call + ) + } + @objc func setIsAvailable(_ call: CAPPluginCall) { sendAsPromise( HypertrackSdkIonicCapacitor.setIsAvailable( @@ -140,6 +148,16 @@ public class HyperTrackCapacitorPlugin: CAPPlugin { ) } + @objc func setWorkerHandle(_ call: CAPPluginCall) { + sendAsPromise( + HypertrackSdkIonicCapacitor.setWorkerHandle( + call.options as! [String: Any] + ), + method: .setWorkerHandle, + call + ) + } + @objc func onSubscribedToErrors(_: CAPPluginCall) { sendErrorsEvent(HyperTrack.errors) } diff --git a/ios/Plugin/common/HyperTrackSDKWrapper.swift b/ios/Plugin/common/HyperTrackSDKWrapper.swift index 27367a2..0184eb2 100644 --- a/ios/Plugin/common/HyperTrackSDKWrapper.swift +++ b/ios/Plugin/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/ios/Plugin/common/SDKMethod.swift b/ios/Plugin/common/SDKMethod.swift index e7c0cd4..0de6f4e 100644 --- a/ios/Plugin/common/SDKMethod.swift +++ b/ios/Plugin/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/ios/Plugin/common/Serialization.swift b/ios/Plugin/common/Serialization.swift index 277a805..d1e4f92 100644 --- a/ios/Plugin/common/Serialization.swift +++ b/ios/Plugin/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/justfile b/justfile index b76484c..d228966 100644 --- a/justfile +++ b/justfile @@ -36,7 +36,7 @@ clean: _clear-node-modules _clear-node-modules: rm -rf node_modules -docs: +docs: build npm run docgen get-dependencies: diff --git a/package-lock.json b/package-lock.json index c65e3be..9421d7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.3.0", + "version": "3.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.3.0", + "version": "3.4.0", "license": "MIT", "devDependencies": { "@capacitor/android": "^5.6.0", @@ -24,6 +24,9 @@ "swiftlint": "^1.0.2", "typedoc": "^0.25.4", "typescript": "^5.3.3" + }, + "peerDependencies": { + "@capacitor/core": "*" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 8b0c0d4..8a46c0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hypertrack-sdk-ionic-capacitor", - "version": "3.3.1", + "version": "3.4.0", "description": "Capacitor plugin for HyperTrack generation SDKs", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", @@ -61,7 +61,9 @@ "typedoc": "^0.25.4", "typescript": "^5.3.3" }, - "peerDependencies": {}, + "peerDependencies": { + "@capacitor/core": "*" + }, "prettier": "@ionic/prettier-config", "swiftlint": "@ionic/swiftlint-config", "eslintConfig": { diff --git a/src/HyperTrack.ts b/src/HyperTrack.ts index 8b0690c..a90cfab 100644 --- a/src/HyperTrack.ts +++ b/src/HyperTrack.ts @@ -14,6 +14,7 @@ import type { LocationInternal } from './data_types/internal/LocationInternal'; import type { LocationWithDeviationInternal } from './data_types/internal/LocationWithDeviationInternal'; import type { Metadata } from './data_types/internal/Metadata'; import type { OrderHandle } from './data_types/internal/OrderHandle'; +import type { WorkerHandle } from './data_types/internal/WorkerHandle'; import { registerPlugin } from '@capacitor/core'; import { Subscription } from './Subscription'; import { Errors, HyperTrackCapacitorPlugin } from './HyperTrackCapacitorPlugin'; @@ -234,6 +235,17 @@ 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 hyperTrackPlugin.getWorkerHandle().then((workerHandle: WorkerHandle) => workerHandle.value); + } + /** * Requests one-time location update and returns the location once it is available, or error. * @@ -319,6 +331,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) { + hyperTrackPlugin.setWorkerHandle({ + type: 'workerHandle', + value: workerHandle, + } as WorkerHandle); + } + /** * Subscribe to tracking errors * diff --git a/src/HyperTrackCapacitorPlugin.ts b/src/HyperTrackCapacitorPlugin.ts index 7cfc3ee..292a7ce 100644 --- a/src/HyperTrackCapacitorPlugin.ts +++ b/src/HyperTrackCapacitorPlugin.ts @@ -1,23 +1,22 @@ -import { EVENT_ERRORS, EVENT_IS_AVAILABLE, EVENT_IS_TRACKING, EVENT_LOCATE, EVENT_LOCATION } from "./HyperTrack"; -import { Subscription } from "./Subscription"; -import { Result } from "./data_types/Result"; -import { DeviceId } from "./data_types/internal/DeviceId"; -import { HyperTrackErrorInternal } from "./data_types/internal/HyperTrackErrorInternal"; -import { IsAvailable } from "./data_types/internal/IsAvailable"; -import { IsTracking } from "./data_types/internal/IsTracking"; -import { LocationErrorInternal } from "./data_types/internal/LocationErrorInternal"; -import { LocationInternal } from "./data_types/internal/LocationInternal"; -import { Metadata } from "./data_types/internal/Metadata"; -import { Name } from "./data_types/internal/Name"; +import { EVENT_ERRORS, EVENT_IS_AVAILABLE, EVENT_IS_TRACKING, EVENT_LOCATE, EVENT_LOCATION } from './HyperTrack'; +import { Subscription } from './Subscription'; +import { Result } from './data_types/Result'; +import { DeviceId } from './data_types/internal/DeviceId'; +import { HyperTrackErrorInternal } from './data_types/internal/HyperTrackErrorInternal'; +import { IsAvailable } from './data_types/internal/IsAvailable'; +import { IsTracking } from './data_types/internal/IsTracking'; +import { LocationErrorInternal } from './data_types/internal/LocationErrorInternal'; +import { LocationInternal } from './data_types/internal/LocationInternal'; +import { Metadata } from './data_types/internal/Metadata'; +import { Name } from './data_types/internal/Name'; +import { WorkerHandle } from './data_types/internal/WorkerHandle'; export type Errors = { - "errors": HyperTrackErrorInternal[] -} + errors: HyperTrackErrorInternal[]; +}; export interface HyperTrackCapacitorPlugin { - addGeotag( - ...args: any[] - ): Promise; + addGeotag(...args: any[]): Promise; getDeviceId(): Promise; @@ -33,6 +32,8 @@ export interface HyperTrackCapacitorPlugin { getName(): Promise; + getWorkerHandle(): Promise; + setIsAvailable(isAvailable: IsAvailable): Promise; setIsTracking(isTracking: IsTracking): Promise; @@ -41,34 +42,27 @@ export interface HyperTrackCapacitorPlugin { setName(name: Name): Promise; + setWorkerHandle(workerHandle: WorkerHandle): Promise; + onSubscribedToErrors(): Promise; onSubscribedToIsAvailable(): Promise; onSubscribedToIsTracking(): Promise; onSubscribedToLocate(): Promise; onSubscribedToLocation(): Promise; - addListener( - eventName: typeof EVENT_ERRORS, - listenerFunc: (error: any) => void - ): Subscription; + addListener(eventName: typeof EVENT_ERRORS, listenerFunc: (error: any) => void): Subscription; - addListener( - eventName: typeof EVENT_IS_AVAILABLE, - listenerFunc: (isAvailable: IsAvailable) => void - ): Subscription; + addListener(eventName: typeof EVENT_IS_AVAILABLE, listenerFunc: (isAvailable: IsAvailable) => void): Subscription; - addListener( - eventName: typeof EVENT_IS_TRACKING, - listenerFunc: (isTracking: IsTracking) => void - ): Subscription; + addListener(eventName: typeof EVENT_IS_TRACKING, listenerFunc: (isTracking: IsTracking) => void): Subscription; addListener( - eventName: typeof EVENT_LOCATE, - listenerFunc: (locateResult: Result) => void + eventName: typeof EVENT_LOCATE, + listenerFunc: (locateResult: Result) => void, ): Subscription; addListener( - eventName: typeof EVENT_LOCATION, - listenerFunc: (location: Result) => void + eventName: typeof EVENT_LOCATION, + listenerFunc: (location: Result) => void, ): Subscription; } diff --git a/src/data_types/internal/WorkerHandle.ts b/src/data_types/internal/WorkerHandle.ts new file mode 100644 index 0000000..4cfa372 --- /dev/null +++ b/src/data_types/internal/WorkerHandle.ts @@ -0,0 +1,4 @@ +export type WorkerHandle = { + type: 'workerHandle'; + value: string; +};