Platform Setup
Complete the platform-specific setup to enable DOTA updates in your app.
- Android
- iOS
Android Setup
In order to integrate DOTA into your Android project, perform the following steps:
- Edit
android/settings.gradleand add the DOTA module:
// ...
include ':app', ':d11_dota'
project(':d11_dota').projectDir = new File(rootProject.projectDir, '../node_modules/@d11/dota/android/app')
- In
android/app/build.gradle, add the dependency:
dependencies {
// ...
implementation project(':d11_dota')
// ...
}
- In
android/app/build.gradle, apply the DOTA build tasks at the end of the file:
// ...
apply from: "../../node_modules/@d11/dota/android/codepush.gradle"
// ...
- Update
MainApplicationto use DOTA:
- RN 0.73+ (Kotlin)
- RN 0.72 and below (Java)
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
// ...
// 2. Add DOTA package for manual linking
add(
CodePush.getInstance(
resources.getString(R.string.CodePushDeploymentKey),
applicationContext,
BuildConfig.DEBUG
)
)
// 3. Let DOTA determine the JS bundle location on each start
override fun getJSBundleFile(): String {
return CodePush.getJSBundleFile()
}
}
}
// 1. Import the plugin class.
import com.microsoft.codepush.react.CodePush;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
// ...
// 2. Add DOTA package for manual linking
packages.add(CodePush.getInstance(
getResources().getString(R.string.CodePushDeploymentKey),
getApplicationContext(),
BuildConfig.DEBUG
));
// 3. Let DOTA determine the JS bundle location on each start
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
}
- Add the deployment key and server URL to
strings.xml:
<resources>
<!-- ... -->
<string moduleConfig="true" name="CodePushDeploymentKey">DeploymentKey</string>
<string moduleConfig="true" name="CodePushServerUrl"><server-url></string>
</resources>
Deployment Key
- Disable autolinking for
@d11/dotaby creatingreact-native.config.jsat the app root:
module.exports = {
dependencies: {
'@d11/dota': {
platforms: {
android: null,
},
},
},
};
iOS Setup
Once you've added the DOTA plugin, integrate it into your Xcode project.
- Objective‑C
- Swift
- Install CocoaPods dependencies:
cd ios && pod install && cd ..
- In
AppDelegate.m, import DOTA headers:
#import <CodePush/CodePush.h>
- Find the production JS source URL and replace it with DOTA:
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
→ Replace with:
return [CodePush bundleURL];
- Use DOTA only for release builds:
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [CodePush bundleURL];
#endif
}
- Add deployment key and server URL to
Info.plist:
<key>CodePushServerURL</key>
<string>server-url</string>
<key>CodePushDeploymentKey</key>
<string>deployment-key</string>
Deployment Key
- Install CocoaPods dependencies:
cd ios && pod install && cd ..
- In
AppDelegate.swift, import CodePush:
import CodePush
- Replace the production JS source URL with DOTA:
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
→ Replace with:
return CodePush.bundleURL()
- Use DOTA only for release builds:
override func bundleURL() -> URL! {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
// Default behavior assumes "main.jsbundle"
return CodePush.bundleURL()
// If you embedded a differently named file:
// return CodePush.bundleURL(forResource: "mybundle")
// return CodePush.bundleURL(forResource: "mybundle", withExtension: "jsbundle")
#endif
}
- Add deployment key and server URL to
Info.plist:
<key>CodePushServerURL</key>
<string>https://dota-sdk.delivr.live/</string>
<key>CodePushDeploymentKey</key>
<string>deployment-key</string>