Skip to content

didStartMonitoringForRegion being called on iOS but not Android #75

Description

@maxmatthews

My app is working perfectly with the following code on iOS, but never calls didStartMonitoringForRegion on Android. Does anyone have any suggestions? Wondering if I'm missing something in my config file. My code and config.xml are below.

Thanks in advance!

function startRanging(uuid, identifier){

        cordova.plugins.locationManager.requestWhenInUseAuthorization(); //request location permission

        $.mobile.loading('show');
        //Ranging - Works only when app is open
        alert('starting ranging method'); // **this gets called on both platforms**

        var delegate = new cordova.plugins.locationManager.Delegate().implement({

            didDetermineStateForRegion: function (pluginResult) {
                cordova.plugins.locationManager.appendToDeviceLog('[DOM] didDetermineStateForRegion: '
                    + JSON.stringify(pluginResult));
            },

            didStartMonitoringForRegion: function (pluginResult) {
                alert('starting ranging'); // **this only gets called on ios**
                console.log('didStartMonitoringForRegion:', pluginResult);
            },

            didRangeBeaconsInRegion: function (pluginResult) {
                var proximity = JSON.stringify(pluginResult.beacons[0].proximity);

                if (proximity != '"ProximityUnknown"'){
                    //alert('beacon found');
                    stopRanging(uuid, identifier);
                    $.mobile.loading('hide');
                    showConfirm();
                }
            }
        });

        var uuid = 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'; //these come in as params now
        var identifier = 'mint';

        var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid);

        cordova.plugins.locationManager.setDelegate(delegate);
        cordova.plugins.locationManager.startRangingBeaconsInRegion(beaconRegion)
            .fail(console.error)
            .done();
    }

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.something.test1" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>Something</name>
    <description>
        Something
    </description>
    <author email="no@spam.com" href="http://nospam.com">
        App Name
    </author>
    <preference name="permissions" value="none" />
    <preference name="phonegap-version" value="3.5.0" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="7" />
    <preference name="android-installLocation" value="auto" />
    <gap:plugin name="org.apache.cordova.splashscreen" />
    <gap:plugin name="org.apache.cordova.dialogs" />
    <gap:plugin name="org.apache.cordova.geolocation" />
    <gap:plugin name="org.apache.cordova.device" />


    <icon src="icon.png" />
    <icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icon/android/icon-36-ldpi.png" />
    <icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icon/android/icon-48-mdpi.png" />
    <icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icon/android/icon-72-hdpi.png" />
    <icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icon/android/icon-96-xhdpi.png" />
    <icon gap:platform="ios" height="57" src="www/res/icon/ios/icon-57.png" width="57" />
    <icon gap:platform="ios" height="72" src="www/res/icon/ios/icon-72.png" width="72" />
    <icon gap:platform="ios" height="114" src="www/res/icon/ios/icon-57-2x.png" width="114" />
    <icon gap:platform="ios" height="144" src="www/res/icon/ios/icon-72-2x.png" width="144" />
    <gap:splash gap:platform="android" gap:qualifier="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
    <gap:splash gap:platform="android" gap:qualifier="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
    <gap:splash gap:platform="android" gap:qualifier="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
    <gap:splash gap:platform="android" gap:qualifier="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
    <gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
    <gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
    <gap:splash gap:platform="ios" height="1136" src="res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" />
    <gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
    <gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />

    <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" />

    <access origin="*" />
</widget>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions