-1

I'm developping a NativeScript application and want to use the WonderPush SDK. I've already used this SDK into a native Android application, so I tried to create a new plugin to wrap the SDK.

I imported the library in the gradle file, and I tried to call the library from the NativeScript plugin. But the library is empty, if I tried to log it with console.dir, the only result is an quasi-empty object:

export class NativescriptWonderpush extends Common {

    init() {
        console.dir(com.wonderpush);
        // com.wonderpush.sdk.Wonderpush.initialize(app.android.context);
    }
}

JS: ==== object dump start ====
JS: sdk: {}
JS: ==== object dump end ====

(The second line com.wonderpush.sdk.Wonderpush.initialize() crash because com.wonderpush.sdk is empty)

Thanks for your help

ofavre
  • 4,488
  • 2
  • 26
  • 23

1 Answers1

0

Native objects may not always be traceable in console like JS objects.

Though you could refer their docs and call the methods you like Or even generate typings if you are using TypeeScript by following the steps given here. The typings ensure that the classes, methods, properties etc., are public and accessible to the JS runtime.

Manoj
  • 21,753
  • 3
  • 20
  • 41
  • I already tried calling the method directly but got an error message: Wonderpush object (from com.wonderpush.sdk) is undefined. But I managed to access it by creating an aar file containing the WonderPush library. So my problem is solved, thanks ! – captainhaddock Apr 09 '19 at 07:40