[MOD-2434] Android: need to implement Android Beacon monitoring on Localytics module
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Medium |
| Status | In Review |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | Fazlul Haque |
| Assignee | Gary Mathews |
| Created | 2018-06-19T22:25:43.000+0000 |
| Updated | 2018-06-20T04:32:57.000+0000 |
Description
Hello,
We have a feature request to update the Android module with beacon monitoring. They have tried the Android localytics module and added the localytics.xml file in the /app/platform/android/res/values directory.
The library was initiated as shown below. It fails calling to find the method - startMonitoring
//Initialization of library:
Alloy.Globals.localytics = require('com.localytics');
Alloy.Globals.localytics.autoIntegrate();
//Start beacon monitoring:
Alloy.Globals.localytics.startMonitoring(handleProximity);
Message: Uncaught TypeError: Alloy.Globals.localytics.startMonitoring is not a function.
They would like to get the startMonitoring method on Android localytics module.
Note: they are using the module from [Here](https://github.com/localytics/localytics-titanium/pull/6)
Thanks
I recommend they use https://github.com/garymathews/liferay-android-beacons/releases/download/2.0/com.liferay.beacons-android-2.0.zip *EXAMPLE*
const beacons = Ti.Platform.name === 'android' ? require('com.liferay.beacons') : null; if (beacons) { // obtain location permissions Ti.Android.requestPermissions([ 'android.permission.ACCESS_FINE_LOCATION' ], (e) => { if (e.success) { // wait for beacons library to be ready let handle = setInterval(() => { if(!beacons.isReady()) return; clearInterval(handle); handle = null; // listen for beacon proximity events beacons.addEventListener('beaconProximity', (e) => { const identifier = e.source.identifier, uuid = e.source.uuid, power = e.source.power; Ti.API.info(identifier: ${identifier}, uuid: ${uuid}, power: ${power}); }); // monitor for our specific beacons beacons.startMonitoringForRegion({ identifier: 'iBeacon', uuid: '1ED323F5-E1CB-6B4C-2418-B8D760237BDE' }); beacons.startMonitoringForRegion({ identifier: 'iBeacon', uuid: 'B9407F30-F5F8-466E-AFF9-25556B57FE6D' }); }, 1000); } else { Ti.API.error(e.error); } }); }