Giter VIP home page Giter VIP logo

ci.geofencing's Introduction

Ci.Geofencing

Overview

This module adds support for using Geofence in iOS Titanium Apps. It can monitor all iOS geofence transitions. This module works when the app is in foreground, background, closed, after phone restart and if location providers get changed.

Download

Download the Ci.Geofence module through the here.

How to use it

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

    var mapview = Titanium.Map.createView({
        mapType : Titanium.Map.STANDARD_TYPE,
        animate : true,
        regionFit : true,
        userLocation : true,
    });

win1.add(mapview);


//
//  add tabs
//
tabGroup.addTab(tab1);   


// open tab group
tabGroup.open();


// TODO: write your module tests here
var ci_geofencing = require('ci.geofencing');
Ti.API.info("module is => " + ci_geofencing);

var regions = []
regions.push({
	"title" : "Willis Tower",
	"latitude" : 41.878844,
	"longitude" : -87.635942,
	"radius" : 100
});

regions.push({
	"title" : "Lincoln Park Zoo",
	"latitude" : 41.92007,
	"longitude" : -87.63251,
	"radius" : 500
});

regions.push({
	"title" : "Chicago Theater",
	"latitude" : 41.88535,
	"longitude" : -87.62745,
	"radius" : 200
});

//
// when firing an event you will get information like this
// {
//    "source": {
//      "id": "ci.geofencing"
//    },
//    "identifier": "Willis Tower",
//    "type": "exited_region" | "entered_region" | "monitoring_region"
//  }
//

ci_geofencing.startGeoFencing(regions, function(event) {
	Ti.API.info('info ' + JSON.stringify(event, null, 2));
	
	if ( event.type === "exited_region") {
		ci_geofencing.stopGeoFencing();
	}
	if ( event.type === "entered_region") {
		alert("Yeah!");
	}
});

ci.geofencing's People

Contributors

aaronksaunders avatar ak0815 avatar deckameron avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.