Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – Beacon monitoring is not working in nativescript vue

Posted on November 14, 2022

Solution 1 :

A few basic troubleshooting steps to perform:

  1. Check what log messages to you see when you run it. This may give you a clue where it is failing.

  2. Confirm if your app has successfully been granted location permission in settings for your app. The instructions to do so vary by platform. if properly configured, you should see a location entry in your app’s permissions list in settings with location granted.

  3. Verify that your uuid, major and minor are correct in this statement: new BeaconRegion(id, uuid, 100, 1) — if you run an off-the shelf beacon detector like Locate Beacon on the same phone, does it detect the beacon with those same identifiers?

Solution 2 :

Solutions:

  1. Add to app.gradle :

    dependencies {
           compile 'org.altbeacon:android-beacon-library:2.15.1'
    }
    
  2. Add this plugin: nativescript-community/ble

  3. Add to AndroidManifest permissions: ACCESS_FINE_LOCATION

In my case this solution detected my beacon.

Problem :

I am using this plugin in Nativescript to use Beacon with the following code:

import {Observable} from 'tns-core-modules/data/observable';
import {
    BeaconRegion, Beacon, BeaconCallback,
    BeaconLocationOptions, BeaconLocationOptionsIOSAuthType, BeaconLocationOptionsAndroidAuthType
} from 'nativescript-ibeacon/nativescript-ibeacon.common';
import {NativescriptIbeacon} from 'nativescript-ibeacon';
export default class BeaconAdapter extends Observable implements BeaconCallback{
  private nativescriptIbeacon: NativescriptIbeacon;

    public message: string = 'Init';

    private region: BeaconRegion = null;

    constructor(id: string, uuid: string) {
        super();
        let options: BeaconLocationOptions = {
          iOSAuthorisationType: BeaconLocationOptionsIOSAuthType.Always,
          androidAuthorisationType: BeaconLocationOptionsAndroidAuthType.Fine,
          androidAuthorisationDescription: 'Location permission needed'
        };
        this.nativescriptIbeacon = new NativescriptIbeacon(this, options);
        this.region = new BeaconRegion(id, uuid, 100, 1);
    }

    start() {
        this.message = 'start';
        if (!this.nativescriptIbeacon.isAuthorised()) {
            console.log('NOT Authorised');
            this.nativescriptIbeacon.requestAuthorization()
                .then(() => {
                    console.log('Authorised by the user');
                    this.nativescriptIbeacon.bind();

                }, (e) => {
                    console.log('Authorisation denied by the user');
                })
        } else {
            console.log('Already authorised');
            this.nativescriptIbeacon.bind();
        }

    }

    stop() {
        this.message = 'stop';
        this.nativescriptIbeacon.stopRanging(this.region);
        this.nativescriptIbeacon.stopMonitoring(this.region);
        this.nativescriptIbeacon.unbind();
    }

    onBeaconManagerReady(): void {
        console.log('onBeaconManagerReady');
        this.nativescriptIbeacon.startRanging(this.region);
        this.nativescriptIbeacon.startMonitoring(this.region);
    }

    didRangeBeaconsInRegion(region: BeaconRegion, beacons: Beacon[]): void {
        //console.log('didRangeBeaconsInRegion: ' + region.identifier + ' - ' + beacons.length);
        //this.message = 'didRangeBeaconsInRegion: ' + (new Date().toDateString());
        for (let beacon of beacons) {
            console.log('B: ' + beacon.proximityUUID + ' - ' + beacon.major + ' - ' + beacon.minor + ' - ' + beacon.distance_proximity + ' - ' + beacon.rssi + ' - ' + beacon.txPower_accuracy );
        }
    }

    didFailRangingBeaconsInRegion(region: BeaconRegion, errorCode: number, errorDescription: string): void {
        console.log('didFailRangingBeaconsInRegion: ' + region.identifier + ' - ' + errorCode + ' - ' + errorDescription);
    }

    didEnterRegion(region: BeaconRegion) {
        //console.log(region);
        console.log('Did enter Region ' + region.identifier);
    }

    didExitRegion(region: BeaconRegion) {
        //console.log(region);
        console.log('Did leave Region '  + region.identifier);
    }

}

But when It starts to monitoring or ranging, does not detect any device even when I have one emitting next to device where I’m testing

READ  [ANSWERED] I can't find the R-File In Android Studio?
Powered by Inline Related Posts

And other question, when the app is running on background, the app crashe with this error(using this plugin)

Not allowed to start service Intent app is in background uid UidRecord

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress