Android SDK
- GitHub
- For Java based app: Android (Java)
The App Upgrade Android SDK helps you to easily integrate with App Upgrade service. This SDK communicate with App Upgrade and check the version with version information in App Upgrade. Based on response it will:
- If app needs force update will show a non-dismissable popup for update. On click it will launch app in app store for user to update.
- If app needs to be updated but not a force update, it will show a dismissable popup.
- If no action is required it won't do anything.
Installation
- Install via gradle Add the JitPack repository to your settings.gradle file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
...
maven { url "https://jitpack.io" }
}
}
If you are using gradle version prior to 7.x.x add the following in your root build.gradle.kts at the end of repositories:
allprojects {
repositories {
...
maven ("https://jitpack.io")
}
}
How to use?
Follow the Getting Started guide to create project and get the x-api-key.
Add the dependency to your project.
dependencies {
implementation 'com.github.appupgrade-dev:app-upgrade-android-sdk:1.0.3'
}
- Internet Permission required. Add the following in AndroidManifest.xml file if not already present.
<uses-permission android:name="android.permission.INTERNET" />
- If you are using
minifyEnabled true
it may obfuscate the code. Add the following rule in proguard-rules.pro to make sure SDK shows the popup.
# Keep all classes in the App Upgrade SDK package
-keep class com.appupgrade.app_upgrade_android_sdk.** { *; }
- Integrate with your app. Add the following code in your MainActivity.kt -> onCreate method.
class MainActivity : AppCompatActivity() {
private lateinit var appUpgrade: AppUpgrade
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// App Upgrade
val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5"
val appInfo = AppInfo(
appId = "com.android.com",
appName = "Wallpaper app",
appVersion = "1.0.0",
platform = "android",
environment = "production",
appLanguage = "es"
)
//Optional
val alertDialogConfig = AlertDialogConfig(
title = "Update Required", //Default: Please Update
updateButtonTitle = "Update Now", //Default: Update Now
laterButtonTitle = "Not Now" //Default: Later
)
val appUpgrade = AppUpgrade()
appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig)
}
}
Note:
- For opening the play store the app should be live.
- It might not be able to open the play store in simulator. You can try it in physical device.
- You can find a sample Kotlin app from here app-upgrade-android-kotlin-demo-app
- Read detailed blog on how to integrate Kotlin app from here How to upgrade/force upgrade Android Kotlin app
Fields
- appId: App Id of your app. Know how to find appId for your app. (Required)
- appName: Your app name. (Required)
- appVersion: Version of your app. (Required)
- platform: This could be android or ios (Required)
- environment: This could be for example development, int, production (Required)
- appLanguage: This is your app language. Example: en, es etc. This will be used to localize the update message. (Optional)
Customizing the Alert popup
You can optionally pass the alertDialogConfig object to customize the alert popup.
- title: Main title shown to user.
- updateButtonTitle: Update button title shown to user.
- laterButtonTitle: Later button title shown to user.
Redirect user to store other than app store or play store.
Supported Stores :
Apple App Store | Google Play Store | Amazon App Store | Huawei AppGallery | Other Android Markets |
---|---|---|---|---|
✓ | ✓ | ✓ | ✓ | ✓ If your app market place isn't one of these you can pass your own store URL. |
If you want users to redirect to store other than app store or playstore. You can add these additional parameters preferredAndroidMarket.
- preferredAndroidMarket: PreferredAndroidMarket.AMAZON // or PreferredAndroidMarket.HUAWEI or PreferredAndroidMarket.OTHER If not provided default is Google playstore. If SDK fails to open preferred market place in case marketplace is not available then default Google playstore will be open.
- otherAndroidMarketUrl: 'https://someotherandroidmarket.com/app/id'// Required if preferredAndroidMarket is Other.
Example:
class MainActivity : AppCompatActivity() {
private lateinit var appUpgrade: AppUpgrade
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// App Upgrade
val xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5"
val appInfo = AppInfo(
appId = "com.android.com",
appName = "Wallpaper app",
appVersion = "1.0.0",
platform = "android",
environment = "production",
appLanguage = "es",
preferredAndroidMarket = PreferredAndroidMarket.HUAWEI // or PreferredAndroidMarket.AMAZON or PreferredAndroidMarket.OTHER If not provided default is Google playstore. Optional
otherAndroidMarketUrl = "https://otherandroidmarketurl.com/app/id" // Required if preferredAndroidMarket is OTHER.
)
val appUpgrade = AppUpgrade()
appUpgrade.checkForUpdates(this, xApiKey, appInfo)
}
}
Screenshot
Changelog
Please see CHANGELOG for more information what has changed recently.
Need help?
If you're looking for help, please write to us at support@appupgrade.dev