diff --git a/package.json b/package.json index 3e7f8960..4caec799 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "version": ">=5.0.0" } ], + "typings": "./typings/cordova-plugin-geofence.d.ts", "devDependencies": { "cordova": "^6.1.1", "cordova-paramedic": "https://github.com/apache/cordova-paramedic" diff --git a/typings/cordova-plugin-geofence.d.ts b/typings/cordova-plugin-geofence.d.ts new file mode 100644 index 00000000..974a5732 --- /dev/null +++ b/typings/cordova-plugin-geofence.d.ts @@ -0,0 +1,61 @@ +interface TransitionType { + ENTER: number; + EXIT: number; + BOTH: number; +} + +interface Window { + geofence: GeofencePlugin; + TransitionType: TransitionType; +} + +interface GeofencePlugin { + initialize( + successCallback?: (result: any) => void, + errorCallback?: (error: string) => void + ): Promise; + + addOrUpdate( + geofence: Geofence | Geofence[], + successCallback?: (result: any) => void, + errorCallback?: (error: string) => void + ): Promise; + + remove( + id: number | number[], + successCallback?: (result: any) => void, + errorCallback?: (error: string) => void + ): Promise; + + removeAll( + successCallback?: (result: any) => void, + errorCallback?: (error: string) => void + ): Promise; + + getWatched( + successCallback?: (result: any) => void, + errorCallback?: (error: string) => void + ): Promise; + + onTransitionReceived: (geofences: Geofence[]) => void; +} + +interface Geofence { + id: string; + latitude: number; + longitude: number; + radius: number; + transitionType: number; + notification?: Notification; +} + +interface Notification { + id?: number; + title?: string; + text: string; + smallIcon?: string; + icon?: string; + openAppOnClick?: boolean; + vibration?: number[]; + data?: Object; +}