Skip to content

Commit aae484d

Browse files
authored
feat(hyper-track): add interfaces to access new cordova plugin APIs (#3698)
1 parent 72335bf commit aae484d

File tree

1 file changed

+55
-2
lines changed
  • src/@ionic-native/plugins/hyper-track

1 file changed

+55
-2
lines changed

src/@ionic-native/plugins/hyper-track/index.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { error } from 'console';
1717
plugin: 'cordova-plugin-hypertrack-v3',
1818
pluginRef: 'hypertrack',
1919
repo: 'https://github.com/hypertrack/cordova-plugin-hypertrack.git',
20-
platforms: ['Android'],
20+
platforms: ['Android, iOS'],
2121
})
2222
@Injectable()
2323
export class HyperTrackPlugin extends IonicNativePlugin {
@@ -26,6 +26,11 @@ export class HyperTrackPlugin extends IonicNativePlugin {
2626
return;
2727
}
2828

29+
@Cordova()
30+
getBlockers(): Promise<Set<Blocker>> {
31+
return;
32+
}
33+
2934
@Cordova()
3035
enableDebugLogging(): Promise<any> {
3136
return;
@@ -59,10 +64,17 @@ interface HyperTrackCordova {
5964
success: SuccessHandler,
6065
error: FailureHandler
6166
): void;
62-
addGeoTag(geotagData: Object, expectedLocation: Coordinates, success: SuccessHandler, error: FailureHandler): void;
67+
addGeoTag(
68+
geotagData: Object,
69+
expectedLocation: Coordinates | undefined,
70+
success: SuccessHandler,
71+
error: FailureHandler
72+
): void;
6373
requestPermissionsIfNecessary(success: SuccessHandler, error: FailureHandler): void;
6474
allowMockLocations(success: SuccessHandler, error: FailureHandler): void;
6575
syncDeviceSettings(success: SuccessHandler, error: FailureHandler): void;
76+
start(success: SuccessHandler, error: FailureHandler): void;
77+
stop(success: SuccessHandler, error: FailureHandler): void;
6678
}
6779

6880
export class CoordinatesValidationError extends Error {}
@@ -76,6 +88,18 @@ export class Coordinates {
7688
}
7789
}
7890

91+
/** A blocker is an obstacle that needs to be resolved to achieve reliable tracking. */
92+
export interface Blocker {
93+
/** Recommended name for a user action, that needs to be performed to resolve the blocker. */
94+
userActionTitle: String;
95+
/** Recommended name for a button, that will navigate user to the place where he can resolve the blocker */
96+
userActionCTA: String;
97+
/** User action explanation */
98+
userActionExplanation: String;
99+
/** An action that navigates user to the dedicated settings menu. */
100+
resolve: () => void;
101+
}
102+
79103
/**
80104
* @usage
81105
* ```typescript
@@ -128,6 +152,15 @@ export class HyperTrack {
128152
});
129153
}
130154

155+
/**
156+
* Get the list of blockers that needs to be resolved for reliable tracking.
157+
*
158+
* @see {Blocker}
159+
*/
160+
static getBlockers(): Promise<Set<Blocker>> {
161+
return new HyperTrackPlugin().getBlockers();
162+
}
163+
131164
/** Resolves device ID that could be used to identify the device. */
132165
getDeviceId(): Promise<string> {
133166
return new Promise((resolve, reject) => {
@@ -230,5 +263,25 @@ export class HyperTrack {
230263
});
231264
}
232265

266+
/** Start tracking. */
267+
start(): Promise<any> {
268+
return new Promise((resolve, reject) => {
269+
this.cordovaInstanceHandle.start(
270+
() => resolve(),
271+
err => reject(err)
272+
);
273+
});
274+
}
275+
276+
/** Stop tracking. */
277+
stop(): Promise<any> {
278+
return new Promise((resolve, reject) => {
279+
this.cordovaInstanceHandle.stop(
280+
() => resolve(),
281+
err => reject(err)
282+
);
283+
});
284+
}
285+
233286
private constructor(private cordovaInstanceHandle: HyperTrackCordova) {}
234287
}

0 commit comments

Comments
 (0)