I am using the sample code given by “Ionic Native IBeacon” but it is not working. When I run it on my device, I just get a blank screen. I recently ran a virtual developer tool and found this error message on the app
"Uncaught TypeError: Cannot read property ‘Delegate’ of undefined
"
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { IBeacon } from '@ionic-native/ibeacon';
@Component({
selector: 'page-about',
templateUrl: 'about.html'
})
export class AboutPage {
constructor(public navCtrl: NavController, private ibeacon: IBeacon) {}
// Request permission to use location on iOS
}
this.ibeacon.requestAlwaysAuthorization();
// create a new delegate and register it with the native layer
let delegate = this.ibeacon.Delegate();
// Subscribe to some of the delegate's event handlers
delegate.didRangeBeaconsInRegion()
.subscribe(
data => alert('didRangeBeaconsInRegion: ' + data),
error => console.error()
);
delegate.didStartMonitoringForRegion()
.subscribe(
data => alert('didStartMonitoringForRegion: ' + data),
error => console.error()
);
delegate.didEnterRegion()
.subscribe(
data => {
alert('didEnterRegion: ' + data);
}
);
let beaconRegion = this.ibeacon.BeaconRegion('deskBeacon','F7826DA6-ASDF-ASDF-8024-BC5B71E0893E');
this.ibeacon.startMonitoringForRegion(beaconRegion)
.then(
() => console.log('Native layer received the request to monitoring'),
error => console.error('Native layer failed to begin monitoring: ', error)
);