Beacons in Appcelerator Titanium

22
BEACONS IN APPCELERATOR TITANIUM

Transcript of Beacons in Appcelerator Titanium

Page 1: Beacons in Appcelerator Titanium

BEACONS IN APPCELERATOR TITANIUM

Page 2: Beacons in Appcelerator Titanium

UUID MAJOR MINOR

Page 3: Beacons in Appcelerator Titanium

IMMEDIATE NEAR FAR

Page 4: Beacons in Appcelerator Titanium

IOS 7.1 > ANDROID 4.3 >

https://developer.apple.com/ibeacon/http://altbeacon.github.io/android-

beacon-library/index.html

https://github.com/jbeuckm/TiBeaconshttps://github.com/dwk5123/android-

altbeacon-module

MAX 20 REGIONS SIMULTANUOUS UNLIMITED REGIONS?

Bluetooth 4.0 / 2.4 Ghz Bluetooth 4.0 / 2.4 Ghz

Page 5: Beacons in Appcelerator Titanium

MONITORING VS RANGING

Page 6: Beacons in Appcelerator Titanium

SIGNAL STRENGTH

RSSI

Page 7: Beacons in Appcelerator Titanium

LOCATION & DIRECTION

Page 8: Beacons in Appcelerator Titanium

LOCATION & DIRECTION

FARNEAR

IMMEDIATE

Page 9: Beacons in Appcelerator Titanium

IMPLEMENTING IN TITANIUM

Page 10: Beacons in Appcelerator Titanium

IOS

Ti.Geolocation.requestAuthorization(Ti.Geolocation.AUTHORIZATION_ALWAYS);

var Beacons = require('org.beuckman.tibeacons');

Beacons.addEventListener('determinedRegionState', function (e) { if (e.regionState === 'inside') { Beacons.startRangingForBeacons({ uuid: e.uuid }); } });

Beacons.addEventListener('beaconProximity', function (beacon) { if (_.isUndefined(beacon.rssi)) return; // do your thing });

Beacons.startMonitoringForRegion({uuid: '<uuid>'});

Page 11: Beacons in Appcelerator Titanium

ANDROID

var Beacons = require('com.drtech.altbeacon');

Beacons.addEventListener('serviceBound', function () { Beacons.startMonitoringForRegion({uuid: '<uuid>'}); });

Beacons.addEventListener('beaconProximity', function (beacon) { if (_.isUndefined(beacon.rssi)) return; // do your thing });

Beacons.setAutoRange(true); Beacons.setRunInService(true); Beacons.addBeaconLayout('m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24');

Beacons.bindBeaconService();

Page 12: Beacons in Appcelerator Titanium

BACKGROUND PROCESSES

THE INTERNET LIES

Page 13: Beacons in Appcelerator Titanium

TIMODULE.XML FOR IOS

<ti:module> <iphone> <plist> <dict> <key>UIBackgroundModes</key> <array> <string>location</string> <string>bluetooth-central</string> <string>bluetooth-peripheral</string> </array> </dict> </plist> </iphone> </ti:module>

Page 14: Beacons in Appcelerator Titanium

TIMODULE.XML FOR IOS

<ti:module> <iphone> <plist> <dict> <key>UIBackgroundModes</key> <array> <string>location</string> <string>bluetooth-central</string> <string>bluetooth-peripheral</string> </array> </dict> </plist> </iphone> </ti:module>

Page 15: Beacons in Appcelerator Titanium

TIMODULE.XML FOR IOS

<ti:module> <iphone> <plist> <dict> <key>UIBackgroundModes</key> <array> <string>location</string> <string>bluetooth-central</string> <string>bluetooth-peripheral</string> </array> </dict> </plist> </iphone> </ti:module>

Page 16: Beacons in Appcelerator Titanium

TIMODULE.XML FOR ANDROID

<ti:module> <android> <manifest> <uses-permission android:name="a….p….BLUETOOTH"/> <uses-permission android:name="a….p….BLUETOOTH_ADMIN"/> <uses-permission android:name="a….p….ACCESS_COARSE_LOCATION"/> <application> <service android:enabled="true" android:exported="false" android:isolatedProcess="false" android:label="beacon" android:name="org.altbeacon.beacon.service.BeaconService"/> <service android:name="org.altbeacon.beacon.BeaconIntentProcessor" android:enabled="true"/> </application> </manifest> </android> </ti:module>

Page 17: Beacons in Appcelerator Titanium

TIMODULE.XML FOR ANDROID

<ti:module> <android> <manifest> <uses-permission android:name="a….p….BLUETOOTH"/> <uses-permission android:name="a….p….BLUETOOTH_ADMIN"/> <uses-permission android:name="a….p….ACCESS_COARSE_LOCATION"/> <application> <service android:enabled="true" android:exported="false" android:isolatedProcess="false" android:label="beacon" android:name="org.altbeacon.beacon.service.BeaconService"/> <service android:name="org.altbeacon.beacon.BeaconIntentProcessor" android:enabled="true"/> </application> </manifest> </android> </ti:module>

Page 18: Beacons in Appcelerator Titanium

DO YOUR THING?

Page 19: Beacons in Appcelerator Titanium

SENSIMITY

Page 20: Beacons in Appcelerator Titanium
Page 21: Beacons in Appcelerator Titanium
Page 22: Beacons in Appcelerator Titanium