简体   繁体   English

将第三方SDK集成到Cordova App中

[英]Integrate third party SDK into Cordova App

How can I integrate a third party SDK into my Cordova App. 如何将第三方SDK集成到我的Cordova应用程序中。

I cannot find any official documentation, only out of date (~2yo) discussions. 我找不到任何正式文档,只有过时的讨论(〜2yo)。

Thanks 谢谢

For Android, you need to reference the .aar in plugin.xml , for example: 对于Android,您需要在plugin.xml引用.aar ,例如:

<platform name="android">
    <source-file src="src/android/libs/my-sdk.aar" target-dir="libs" framework="true" />

You also need to create a Gradle config file which references it, for example src/android/libs/my-sdk.gradle should contain: 您还需要创建一个引用它的Gradle配置文件,例如src/android/libs/my-sdk.gradle应该包含:

repositories{
    jcenter()
    flatDir{
        dirs 'libs'
    }
}

dependencies {
    compile(name:'my-sdk', ext:'aar')
}

android {
    packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}

And place a reference to the Gradle file in plugin.xml : 并在plugin.xml放置对Gradle文件的引用:

<platform name="android">
    <framework src="src/android/libs/my-sdk.gradle" custom="true" type="gradleReference" /> 

For iOS, you need to import the compiled static library in plugin.xml : 对于iOS,您需要在plugin.xml导入已编译的静态库:

<platform name="ios">
    <source-file src="src/ios/libs/libMySDK.a" framework="true" />

You then need to include top-level header file(s) for your library in your plugin and reference them from plugin.xml : 然后,您需要在插件中包含库的顶级头文件,并从plugin.xml引用它们:

<platform name="ios">
    <header-file src="src/ios/Headers/MySDK.h"/>

You can use other existing plugins as working examples, such as movintracks/cordova-plugin which uses .aar for an Android library and .a for iOS. 您可以使用其他现有插件作为工作示例,例如movintracks / cordova-plugin ,该插件在Android库中使用.aar ,在iOS中使用.a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM