fix(geofence): fix event listeners
This commit is contained in:
parent
abfa8a5f0f
commit
efa222fb55
@ -20,7 +20,7 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
* )
|
* )
|
||||||
* })
|
* })
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* private addGeofence() {
|
* private addGeofence() {
|
||||||
* //options describing geofence
|
* //options describing geofence
|
||||||
* let fence = {
|
* let fence = {
|
||||||
@ -36,13 +36,13 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
* openAppOnClick: true //open app when notification is tapped
|
* openAppOnClick: true //open app when notification is tapped
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Geofence.addOrUpdate(fence).then(
|
* Geofence.addOrUpdate(fence).then(
|
||||||
* () => console.log('Geofence added'),
|
* () => console.log('Geofence added'),
|
||||||
* (err) => console.log('Geofence failed to add')
|
* (err) => console.log('Geofence failed to add')
|
||||||
* );
|
* );
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* ### Transition Types ###
|
* ### Transition Types ###
|
||||||
* Transition type specifies whether the geofence should trigger when the user enters and/or leaves the geofence.
|
* Transition type specifies whether the geofence should trigger when the user enters and/or leaves the geofence.
|
||||||
@ -67,7 +67,7 @@ import { Observable } from 'rxjs/Observable';
|
|||||||
*
|
*
|
||||||
* ### Troubleshooting ###
|
* ### Troubleshooting ###
|
||||||
* #### I get compile errors when I run `ionic build ios` or `ionic run ios`. ####
|
* #### I get compile errors when I run `ionic build ios` or `ionic run ios`. ####
|
||||||
* This could be caused by the Cordova project directory in `/platforms/ios` not being named correctly.
|
* This could be caused by the Cordova project directory in `/platforms/ios` not being named correctly.
|
||||||
* Try running `ionic platform rm <platform>` then run `ionic platform add <platform>` to recreate the
|
* Try running `ionic platform rm <platform>` then run `ionic platform add <platform>` to recreate the
|
||||||
* platform directories.
|
* platform directories.
|
||||||
*/
|
*/
|
||||||
@ -97,7 +97,7 @@ export class Geofence {
|
|||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static initialize(): Promise<void> { return };
|
static initialize(): Promise<void> { return };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new geofence or array of geofences. For geofence object, see above.
|
* Adds a new geofence or array of geofences. For geofence object, see above.
|
||||||
*
|
*
|
||||||
@ -105,16 +105,16 @@ export class Geofence {
|
|||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static addOrUpdate(geofences: Object | Array<Object>): Promise<void> { return };
|
static addOrUpdate(geofences: Object | Array<Object>): Promise<void> { return };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a geofence or array of geofences. `geofenceID` corresponds to one or more IDs specified when the
|
* Removes a geofence or array of geofences. `geofenceID` corresponds to one or more IDs specified when the
|
||||||
* geofence was created.
|
* geofence was created.
|
||||||
*
|
*
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static remove(geofenceId: string | Array<string>): Promise<void> { return };
|
static remove(geofenceId: string | Array<string>): Promise<void> { return };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all geofences.
|
* Removes all geofences.
|
||||||
*
|
*
|
||||||
@ -122,7 +122,7 @@ export class Geofence {
|
|||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
static removeAll(): Promise<void> { return };
|
static removeAll(): Promise<void> { return };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of geofences currently being monitored.
|
* Returns an array of geofences currently being monitored.
|
||||||
*
|
*
|
||||||
@ -132,18 +132,16 @@ export class Geofence {
|
|||||||
static getWatched(): Promise<string> { return };
|
static getWatched(): Promise<string> { return };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a geofence is crossed in the direction specified by `TransitType`.
|
* Called when a geofence is crossed in the direction specified by `TransitType`.
|
||||||
* Commenting out. Not yet implemented in plugin.
|
* Commenting out. Not yet implemented in plugin.
|
||||||
*
|
*
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
|
||||||
static onTransitionReceived(): Observable<any> {
|
static onTransitionReceived(): Observable<any> {
|
||||||
|
|
||||||
return new Observable<any>((observer) => {
|
return new Observable<any>((observer) => {
|
||||||
window.geofence.onTransitionReceived = observer.next.bind(observer);
|
window && window.geofence && (window.geofence.onTransitionReceived = observer.next.bind(observer));
|
||||||
return null;
|
return () => window.geofence.onTransitionReceived = () => {};
|
||||||
// undefined can be replaced with ()=>{} .. whichever works better
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -154,15 +152,13 @@ export class Geofence {
|
|||||||
*
|
*
|
||||||
* @return {Promise<Object>}
|
* @return {Promise<Object>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
|
||||||
static onNotificationClicked(): Observable<any> {
|
static onNotificationClicked(): Observable<any> {
|
||||||
|
|
||||||
return new Observable<any>((observer) => {
|
return new Observable<any>((observer) => {
|
||||||
window.geofence.onNotificationClicked = observer.next.bind(observer);
|
window && window.geofence && (window.geofence.onNotificationClicked = observer.next.bind(observer));
|
||||||
return () => window.geofence.onNotificationClicked = () => {}
|
return () => window.geofence.onNotificationClicked = () => {};
|
||||||
// undefined can be replaced with ()=>{} .. whichever works better
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user