Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Scott christocracy

View GitHub Profile
View getCurrentPosition.java
package com.transistorsoft.cordova.bggeo;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONException;
import org.json.JSONObject;
import com.transistorsoft.locationmanager.adapter.BackgroundGeolocation;
import com.transistorsoft.locationmanager.adapter.callback.TSLocationCallback;
import com.transistorsoft.locationmanager.event.ActivityChangeEvent;
import com.transistorsoft.locationmanager.event.GeofenceEvent;
View background-geolocation-ionic.ts
/**
* How to implement cordova-background-geolocation with Ionic 2 / 3
* @see https://github.com/transistorsoft/cordova-background-geolocation-lt
* @author Chris Scott, Transistor Software <chris@transistorsoft.com>
*/
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
View flutter_background_geolocation_helloworld.dart
/**
* flutter_background_geolocation Hello World
* https://github.com/transistorsoft/flutter_background_geolocation
*/
import 'package:flutter/material.dart';
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
////
// For pretty-printing location JSON. Not a requirement of flutter_background_geolocation
@christocracy
christocracy / BackgroundGeolocation-Ionic2.js
Last active Sep 6, 2018
Simple Cordova Background Geolocation Implementation for Ionic 2 / 3
View BackgroundGeolocation-Ionic2.js
/**
* 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>
*/
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
@christocracy
christocracy / geofencing.js
Last active Oct 11, 2016
Background Geolocation Geofencing
View geofencing.js
// Listen for geofence events.
bgGeo.on('geofence', function(params) {
console.log('- Geofence event: ', params.identifier);
});
// Add a geofence
bgGeo.addGeofences({
identifier: 'HOME',
radius: 200,
latitude: 45.51818958022214,
longitude: -73.61409989192487,
@christocracy
christocracy / scheduler-splash.js
Last active Oct 11, 2016
Background Geolocation Scheduler
View scheduler-splash.js
bgGeo.configure({
startOnBoot: true, // Scheduler will start when device is rebooted.
schedule: [
'2,4 6:00-19:00', // Mon,Wed: 6:00am-7:00pm
'3 11:00-14:00', // Tue: 11:00am-2:00pm
'6 6:00-7:00', // Fri: 6:00am-7:00am
'6 8:00-19:00', // Fri: 8:00am-7:00pm
'2-6 20:00-21:00' // Mon-Fri: 8:00pm-9:00pm
]
}, function() {
@christocracy
christocracy / scheduler.js
Last active Apr 30, 2016
Sample of new Background Geolocation scheduling schema.
View scheduler.js
bgGeo.configure({
.
.
.
schedule: [
'1 17:30-21:00', // Sunday: 5:30-9:00
'2-6 9:00-17:00', // Mon-Fri: 9am to 5pm
'2,4,6 20:00-12:00',// Mon, Web, Fri: 8pm to midnight (next day)
'7 10:00-19:00' // Sun: 10am-7pm
]
@christocracy
christocracy / LifecycleEventLIstener.java
Last active Jun 24, 2022
Listening to React-Native life-cycle events in your custom Views or Modules
View LifecycleEventLIstener.java
public class MyView extends SimpleViewManager<MapView> {
public static final String TAG = "MyView";
@Override
public String getName() {
return TAG;
}
@Override
protected MapView createViewInstance(ThemedReactContext context) {
View gist:03bf7c29be3636e8dbd0
{
"device": {
"available": true,
"platform": "Android",
"version": "5.1.1",
"uuid": "125c663531f37f55",
"cordova": "4.1.1",
"model": "Nexus 5",
"manufacturer": "LGE"
},
View Location.json
object:
{
"location": {
"coords": {
"latitude": [Float],
"longitude": [Float]
"accuracy": [Float]
"speed": [Float],
"heading": [Float],