Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2434] Android: need to implement Android Beacon monitoring on Localytics module

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusIn Review
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterFazlul Haque
AssigneeGary Mathews
Created2018-06-19T22:25:43.000+0000
Updated2018-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

Comments

  1. Gary Mathews 2018-06-19

    I recommend they use https://github.com/garymathews/liferay-android-beacons/releases/download/2.0/com.liferay.beacons-android-2.0.zip *EXAMPLE*
       <android xmlns:android="http://schemas.android.com/apk/res/android">
         <manifest>    
           <uses-permission android:name="android.permission.BLUETOOTH"/>
           <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
           <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
       
           <application>
             <service android:enabled="true" android:exported="true" android:isolatedProcess="false" android:label="iBeacon" android:name="com.radiusnetworks.ibeacon.service.IBeaconService"/>
             <service android:enabled="true" android:name="com.radiusnetworks.ibeacon.IBeaconIntentProcessor">
               <meta-data android:name="background" android:value="true"/>
               <intent-filter android:priority="1">
                 <action android:name="${applicationId}.DID_RANGING"/>
                 <action android:name="${applicationId}.DID_MONITORING"/>
               </intent-filter>
             </service>
           </application>
       
         </manifest>
       </android>
       
       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);
               }
           });
       }
       

JSON Source