feat(hyper-track): add interfaces to access new cordova plugin APIs (#3698)

This commit is contained in:
deniszpua 2021-08-02 23:40:22 +03:00 committed by GitHub
parent 72335bfd59
commit aae484dfe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<Set<Blocker>> {
return;
}
@Cordova()
enableDebugLogging(): Promise<any> {
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<Set<Blocker>> {
return new HyperTrackPlugin().getBlockers();
}
/** Resolves device ID that could be used to identify the device. */
getDeviceId(): Promise<string> {
return new Promise((resolve, reject) => {
@ -230,5 +263,25 @@ export class HyperTrack {
});
}
/** Start tracking. */
start(): Promise<any> {
return new Promise((resolve, reject) => {
this.cordovaInstanceHandle.start(
() => resolve(),
err => reject(err)
);
});
}
/** Stop tracking. */
stop(): Promise<any> {
return new Promise((resolve, reject) => {
this.cordovaInstanceHandle.stop(
() => resolve(),
err => reject(err)
);
});
}
private constructor(private cordovaInstanceHandle: HyperTrackCordova) {}
}