Android SDK

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" />
  • 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:

  1. For opening the play store the app should be live.
  2. It might not be able to open the play store in simulator. You can try it in physical device.
  3. You can find a sample Kotlin app from here app-upgrade-android-kotlin-demo-app
  4. 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

forceupgrade_android_kotlin

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

© 2022-2023 | App Upgrade | All Rights Reserved            Updated 2023-09-05 22:32:32

results matching ""

    powered by algolia

    No results matching ""