mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 08:32:52 +08:00
feat(hyper-track): add interfaces to access new cordova plugin APIs (#3698)
This commit is contained in:
parent
72335bfd59
commit
aae484dfe9
@ -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) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user