How can I integrate a third party SDK into my Cordova App.
I cannot find any official documentation, only out of date (~2yo) discussions.
Thanks
For Android, you need to reference the .aar
in plugin.xml
, for example:
<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:
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
:
<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
:
<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
:
<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.