iBeacon Plugin in Ionic 5

Hi,
in my project, the iBeacon plugin doesn’t fire delegate.didRangeBeaconsInRegion() event.
Only delegate.didStartMonitoringForRegion() event is triggered
only once the delegate.didRangeBeaconsInRegion() event works fine with range all beacons after close and open nothing happend and before it work’s the event not fire also. So completly random.

Here my code:

import {Component, OnInit} from ‘@angular/core’;
import {IBeacon} from ‘@ionic-native/ibeacon/ngx’;

@Component({
selector: ‘app-store’,
templateUrl: ‘./store.page.html’,
styleUrls: [’./store.page.scss’],
})
export class StorePage implements OnInit {

beacons: any[] = [];

constructor(private ibeacon: IBeacon) {

}

ionViewWillEnter() {
    // Request permission to use location on iOS
    this.ibeacon.requestAlwaysAuthorization();
    // create a new delegate and register it with the native layer
    const delegate = this.ibeacon.Delegate();
    // Subscribe to some of the delegate's event handlers
    delegate.didRangeBeaconsInRegion()
        .subscribe(
            data => {
                console.log('didRangeBeaconsInRegion: ', data);
                if (data.beacons.length > 0) {
                    data.beacons.forEach(beacon => {
                        this.beacons.push(beacon);
                    });
                }
            },
            error => console.error(error)
        );
    delegate.didStartMonitoringForRegion()
        .subscribe(
            data => console.log('didStartMonitoringForRegion: ', data),
            error => console.error(error)
        );
    delegate.didEnterRegion()
        .subscribe(
            data => {
                console.log('didEnterRegion: ', data);
            },
            error => console.error(error)
        );

    const beaconRegion = this.ibeacon.BeaconRegion('RegionName', 'xxx); // UUID hide

    this.ibeacon.startMonitoringForRegion(beaconRegion)
        .then(
            () => console.log('Native layer received the request to monitoring'),
            error => console.error('Native layer failed to begin monitoring: ', error)
        );
}

ngOnInit() {

}

}

$ ionic info

Ionic:

Ionic CLI : 5.4.16 (C:\Users\XXX\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 5.2.3
@angular-devkit/build-angular : 0.901.11
@angular-devkit/schematics : 9.1.11
@angular/cli : 9.1.11
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0-nightly.2019.9.10.42c0cba7
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 5 other plugins)

Utility:

cordova-res : 0.15.1
native-run : 1.0.0

System:

Android SDK Tools : 26.1.1 (C:\Users\XXX\AppData\Local\Android\sdk)
NodeJS : v13.12.0 (D:\Programme\NodeJS\node.exe)
npm : 6.14.4
OS : Windows 10

Nobody has an idea?
There are alternative frameworks with IBeacon support that are recommended?

It doesn’t seem to work with Ionic

Hi, i’ve the same problem, did you find a solution ? thanks

Hi, same problem for me.

Same code

Ionic info : 
Ionic CLI                     : 6.12.4 ()
   Ionic Framework               : @ionic/angular 5.5.3
   @angular-devkit/build-angular : 0.1100.7
   @angular-devkit/schematics    : 11.0.7
   @angular/cli                  : 11.0.7
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res : 0.15.3
   native-run  : 1.3.0

System:

   NodeJS : v12.19.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.8
   OS     : Windows 10

Do you have a solution please?

You have to use startRangingBeaconsInRegion(region) method for start to monitor rangingBeacons