Last active
September 6, 2018 15:31
Revisions
-
christocracy revised this gist
Jan 27, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ /** * How to implement cordova-background-geolocation with Ionic 2 / 3 * https://github.com/transistorsoft/cordova-background-geolocation-lt * Chris Scott, Transistor Software <chris@transistorsoft.com> */ -
christocracy revised this gist
Jan 27, 2018 . No changes.There are no files selected for viewing
-
christocracy revised this gist
Feb 9, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export class HomePage { this.bgGeo.on('motionchange', this.onMotionChange.bind(this)); this.bgGeo.on('activitychange', this.onActivityChange.bind(this)); this.bgGeo.on('geofence', this.onGeofence.bind(this)); this.bgGeo.on('http', this.onHttpSuccess.bind(this), this.onHttpFailure.bind(this)); // 3. Configure it. this.bgGeo.configure({ -
christocracy created this gist
Feb 9, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ /** * How to implement cordova-background-geolocation with Ionic 2 * https://github.com/transistorsoft/cordova-background-geolocation-lt * Chris Scott, Transistor Software <chris@transistorsoft.com> */ import { Component } from '@angular/core'; import { NavController, Platform } from 'ionic-angular'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { /** * Reference to BackgroundGeolocation */ private bgGeo: any; constructor(public navCtrl: NavController, public platform: Platform) { platform.ready().then(this.configureBackgroundGeolocation.bind(this)); } configureBackgroundGeolocation() { // 1. Get a reference to the plugin this.bgGeo = (<any>window).BackgroundGeolocation; // 2. Listen to events this.bgGeo.on('location', this.onLocation.bind(this)); this.bgGeo.on('motionchange', this.onMotionChange.bind(this)); this.bgGeo.on('activitychange', this.onActivityChange.bind(this)); this.bgGeo.on('geofence', this.onGeofence.bind(this)); this.bgGeo.on('http', this.onHttpSuccess, this.onHttpFailure.bind(this)); // 3. Configure it. this.bgGeo.configure({ debug: true, desiredAccuracy: 0, distanceFilter: 10, url: 'http://192.168.11.100:8080/locations', autoSync: true }, (state) => { // 4. Start the plugin. this.bgGeo.start(); }); } onLocation(location, taskId) { console.log('- location: ', location); this.bgGeo.finish(taskId); } onMotionChange(isMoving, location, taskId) { console.log('- motionchange: ', isMoving, location); this.bgGeo.finish(taskId); } onActivityChange(activity) { console.log('- activitychange: ', activity); } onGeofence(params, taskId) { console.log('- geofence: ', params); this.bgGeo.finish(taskId); } onHttpSuccess(response) { console.log('- http success: ', response); } onHttpFailure(response) { console.log('- http failure: ', response); } }