From aae484dfe96bf36ece91f7aca617faa3c0650e28 Mon Sep 17 00:00:00 2001 From: deniszpua Date: Mon, 2 Aug 2021 23:40:22 +0300 Subject: [PATCH] feat(hyper-track): add interfaces to access new cordova plugin APIs (#3698) --- .../plugins/hyper-track/index.ts | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/@ionic-native/plugins/hyper-track/index.ts b/src/@ionic-native/plugins/hyper-track/index.ts index 817e2b333..db9d2d8e4 100644 --- a/src/@ionic-native/plugins/hyper-track/index.ts +++ b/src/@ionic-native/plugins/hyper-track/index.ts @@ -17,7 +17,7 @@ import { error } from 'console'; plugin: 'cordova-plugin-hypertrack-v3', pluginRef: 'hypertrack', repo: 'https://github.com/hypertrack/cordova-plugin-hypertrack.git', - platforms: ['Android'], + platforms: ['Android, iOS'], }) @Injectable() export class HyperTrackPlugin extends IonicNativePlugin { @@ -26,6 +26,11 @@ export class HyperTrackPlugin extends IonicNativePlugin { return; } + @Cordova() + getBlockers(): Promise> { + return; + } + @Cordova() enableDebugLogging(): Promise { return; @@ -59,10 +64,17 @@ interface HyperTrackCordova { success: SuccessHandler, error: FailureHandler ): void; - addGeoTag(geotagData: Object, expectedLocation: Coordinates, success: SuccessHandler, error: FailureHandler): void; + addGeoTag( + geotagData: Object, + expectedLocation: Coordinates | undefined, + success: SuccessHandler, + error: FailureHandler + ): void; requestPermissionsIfNecessary(success: SuccessHandler, error: FailureHandler): void; allowMockLocations(success: SuccessHandler, error: FailureHandler): void; syncDeviceSettings(success: SuccessHandler, error: FailureHandler): void; + start(success: SuccessHandler, error: FailureHandler): void; + stop(success: SuccessHandler, error: FailureHandler): void; } export class CoordinatesValidationError extends Error {} @@ -76,6 +88,18 @@ export class Coordinates { } } +/** A blocker is an obstacle that needs to be resolved to achieve reliable tracking. */ +export interface Blocker { + /** Recommended name for a user action, that needs to be performed to resolve the blocker. */ + userActionTitle: String; + /** Recommended name for a button, that will navigate user to the place where he can resolve the blocker */ + userActionCTA: String; + /** User action explanation */ + userActionExplanation: String; + /** An action that navigates user to the dedicated settings menu. */ + resolve: () => void; +} + /** * @usage * ```typescript @@ -128,6 +152,15 @@ export class HyperTrack { }); } + /** + * Get the list of blockers that needs to be resolved for reliable tracking. + * + * @see {Blocker} + */ + static getBlockers(): Promise> { + return new HyperTrackPlugin().getBlockers(); + } + /** Resolves device ID that could be used to identify the device. */ getDeviceId(): Promise { return new Promise((resolve, reject) => { @@ -230,5 +263,25 @@ export class HyperTrack { }); } + /** Start tracking. */ + start(): Promise { + return new Promise((resolve, reject) => { + this.cordovaInstanceHandle.start( + () => resolve(), + err => reject(err) + ); + }); + } + + /** Stop tracking. */ + stop(): Promise { + return new Promise((resolve, reject) => { + this.cordovaInstanceHandle.stop( + () => resolve(), + err => reject(err) + ); + }); + } + private constructor(private cordovaInstanceHandle: HyperTrackCordova) {} }