0

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?

Andy J.
  • 344
  • 2
  • 4
  • 14
  • I guess you are missing the `onSatelliteStatusChanged` method implementation, try adding that. – Manoj Jan 28 '20 at 04:25
  • @Manoj it would be great if you could provide a code snippet how to do this in NativeScript – Andy J. Jan 28 '20 at 09:38
  • Try `new android.location.GnssStatus.Callback({onSatelliteStatusChanged: function(status){}});` – Manoj Jan 28 '20 at 16:10
  • Thanks for this snippet :). Unfortunately it didn't work for me: `cannot marshal javascript argument object object at index 0 to java type` – Andy J. Jan 29 '20 at 13:34

1 Answers1

1

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) {

    }
  }
Manoj
  • 21,753
  • 3
  • 20
  • 41
  • Looks good. Thanks for your answer! Not tested it yet. Will come back to this task soon to will leave the feedback here. – Andy J. Feb 05 '20 at 11:48