How to use an external sdk with Nativescript

时间:2019-04-08 13:16:37

标签: android nativescript

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

1 个答案:

答案 0 :(得分:0)

本地对象可能并不总是可以像JS对象一样在控制台中被跟踪。

尽管您可以参考他们的文档并调用自己喜欢的方法,或者如果您使用TypeeScript,则可以按照here给出的步骤生成类型。键入确保类,方法,属性等是公共的,并且可供JS运行时访问。