ionic plugin add cordova-plugin-ibeacon
I am using native-plugin(above mentioned) detection but it’s not working for IOS and the same plugin is working for Android.
ionic plugin add cordova-plugin-ibeacon
I am using native-plugin(above mentioned) detection but it’s not working for IOS and the same plugin is working for Android.
Works for me using iOS11 on the iPhone X - Can you share your code?
import { Injectable } from '@angular/core';
import { Platform, Events } from 'ionic-angular';
import { IBeacon } from 'ionic-native';
@Injectable()
export class BeaconProvider {
delegate: any;
region: any;
constructor(public platform: Platform, public events: Events) {
// cordova.plugins.locationManager.requestAlwaysAuthorization();
}
initialise(): any {
let promise = new Promise((resolve, reject) => {
// we need to be running on a device
if (this.platform.is('cordova')) {
// Request permission to use location on iOS
IBeacon.requestAlwaysAuthorization();
// create a new delegate and register it with the native layer
this.delegate = IBeacon.Delegate();
// Subscribe to some of the delegate's event handlers
this.delegate.didRangeBeaconsInRegion()
.subscribe(
data => {
this.events.publish('didRangeBeaconsInRegion', data);
},
error => console.error()
);
// setup a beacon region
this.region = IBeacon.BeaconRegion('deskBeacon', '4B54504C-5546-4F00-0000-000000000001');
// start ranging
IBeacon.startRangingBeaconsInRegion(this.region)
.then(
() => {
resolve(true);
},
error => {
console.error('Failed to begin monitoring: ', error);
resolve(false);
}
);
} else {
console.error("This application needs to be running on a device");
resolve(false);
}
});
return promise;
}
}
This is my beacon-provider code.