Can Anyone provide me a working code in ionic of transmitting and scanning ble beacon on the same mobile device

I have tried many thing and I came accross 2 liberaries:-

  1. For Eddystone :- https://evothings.com/detecting-eddystone-beacons-in-javascript-made-easy/
  2. For Ibeacon :- https://github.com/petermetz/cordova-plugin-ibeacon

But as I am new to the ionic development, I am not able to write a proper working code. Please do help! Thanks in Advance.

People are not going to write the code for you. The community is here to help, but please share what you’ve tried first instead of asking for code.

import {ChangeDetectorRef, Component} from '@angular/core';
import { Platform} from 'ionic-angular';
import {IBeacon} from "@ionic-native/ibeacon";
import {isBoolean} from "ionic-angular/util/util";
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  homePage: string =null;
  outputdata: any;
  outputerror: any;
  inputdata: any;
  inputerror: any;
  beaconData: any;
  advertinputdata: any;
  advertavailinputerror: any;
  buke: any;
  auther: any;


  constructor(public change: ChangeDetectorRef,
              public platform: Platform,
              private ibeacon: IBeacon,) {
    this.homePage =  "1000";
  }
 watch() {
     this.ibeacon.getAuthorizationStatus().then(
      data => this.auther = data.authorizationStatus,
      error => console.error(error)
    )
   this.platform.ready().then(()=>{
     this.ibeacon.isBluetoothEnabled().then(
       ()=> this.buke = isBoolean(this.ibeacon.isBluetoothEnabled()),
       error => console.error(error)
     )
     this.ibeacon.startAdvertising(this.ibeacon.BeaconRegion('deskBeacon', '7813eab4-9ee5-447b-b3ee-6179c9b9877a', 10, 10, true), -59).then(
       () => this.inputdata = "yay!" + console.log("yay! task done"),
       error => console.error(error)
     )
     this.ibeacon.isAdvertising().then(
       () => this.advertinputdata = isBoolean(this.ibeacon.isAdvertising())  ,
       error => console.error(error)
     )

   })

}
monitor(){
  this.platform.ready().then(()=>{
    // 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 => this.outputdata = data,
        error => console.error()
      );
    delegate.didStartMonitoringForRegion()
      .subscribe(
        data => console.log('didStartMonitoringForRegion: ', data),
        error => console.error()
      );
    delegate.didEnterRegion()
      .subscribe(
        data => {
          console.log('didEnterRegion: ', data);
        }
      );

    let beaconRegion = this.ibeacon.BeaconRegion('deskBeacon','7813eab4-9ee5-447b-b3ee-6179c9b9877a');

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

  }

}

the output that i am getting is :
.isAdvertising() = false
.isBluetoothEnabled() =false
.getAuthorizationStatus() = authorised
.startAdvertising()= i am getting yay but its not advertising

plus when i was trying evothing’s eddystone after adding the plugin the advertising code is not working as the downloaded plugin’s code itself doesn’t has the startadvertising function but online where i see the source code it is present

That function is annotated @hidden, which I take to mean that it should not be referenced in app code.

Since isBluetoothEnabled returns a Promise, this expression will always be false. Same story for isAdvertising.

whats the solution i could try to solve this and get the device advertising?