cordova-plugin-ibeacon icon indicating copy to clipboard operation
cordova-plugin-ibeacon copied to clipboard

Advertising doesn't work in background iOS

Open jarekskuder opened this issue 6 years ago • 2 comments

Hi, I'm trying to advertise my app as iBeacon, everything works well with Android (it works in foreground and background as well), but in iOS it doesn't work in background.

Here is my code:

   cordova.plugins.locationManager.requestAlwaysAuthorization();

    var uuid = '588490E5-2884-4046-9F2B-78FFE47C796A';
    var identifier = 'TEST';
    var minor = 1000;
    var major = 1;
    var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor);

    var delegate = new cordova.plugins.locationManager.Delegate();

    delegate.peripheralManagerDidStartAdvertising = function(pluginResult) {
        console.log('peripheralManagerDidStartAdvertising: '+ JSON.stringify(pluginResult.region));
    };

    delegate.peripheralManagerDidUpdateState = function(pluginResult) {
        console.log('peripheralManagerDidUpdateState: '+ pluginResult.state);
    };

    cordova.plugins.locationManager.setDelegate(delegate);

    cordova.plugins.locationManager.isAdvertisingAvailable()
        .then(function(isSupported){
            if (isSupported) {
                cordova.plugins.locationManager.startAdvertising(beaconRegion)
                    .fail(console.error)
                    .done();
            } else {
                console.log("Advertising not supported");
            }
        })
        .fail(function(e) { console.error(e); })
        .done();

I added NSLocationAlwaysAndWhenInUseUsageDescription via config-file, it adds in to Info.plist (i checked in Xcode).

I enabled Location updates in Capabilities.

Testing on iPhone 6s, iOS 11.0.1 Cordova 7.1.0 iOS platform 4.5.4

jarekskuder avatar Nov 20 '18 09:11 jarekskuder

@jarekskuder Running into similar issues... were you able to resolve anything?

stevenatciklum avatar Jan 08 '19 17:01 stevenatciklum

same here...

jeremyTyriaux avatar Feb 26 '19 10:02 jeremyTyriaux