Get additional geolocation data (GnssStatus) in NativeScript application

193 Views Asked by At

In my NativeScript app I need to get additional geolocation info like satellite count or satellite ids which isn't provided by nativescript-geolocation plugin.

I am trying to use GnssStatus class from android.location in NativeScript app with the following:

const gnssCb = new android.location.GnssStatus.Callback();

After that I get an error:

ERROR Error: JNI Exception occurred (SIGABRT)

What am I doing wrong? Or is there any alternative way I can get that info?

1

There are 1 best solutions below

1
On

android.location.GnssStatus.Callback is a class inherited from Object, so you may have to extend it to override the methods. I tested below code with Playground, it executes as expected.

class MyGnssStatus extends android.location.GnssStatus.Callback {
    constructor() {
      super();
      return global.__native(this);
    }

    onSatelliteStatusChanged(status) {

    }
  }