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 at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url '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.java -> onCreate method.

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // App Upgrade
        String xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5";

        String appId = "com.android.com";
        String appName = "Wallpaper app";
        String appVersion = "1.0.0";
        String platform = "android";
        String environment = "production";
        String appLanguage = "es"; //Nullable

        AppInfo appInfo = new AppInfo(appId, appName, appVersion, platform, environment, appLanguage);

        // Optional
        String title = "Update Required.";
        String updateButtonTitle = "UPDATE";
        String laterButtonTitle = "Not Now";
        AlertDialogConfig alertDialogConfig = new AlertDialogConfig(title, updateButtonTitle, laterButtonTitle);

        AppUpgrade appUpgrade = new 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 Java app from here app-upgrade-android-java-demo-app
  4. Read detailed blog on how to integrate Java app from here How to upgrade/force upgrade Android Java 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:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // App Upgrade
        String xApiKey = "ZWY0ZDhjYjgtYThmMC00NTg5LWI0NmUtMjM5OWZkNjkzMzQ5";

        String appId = "com.android.com";
        String appName = "Wallpaper app";
        String appVersion = "1.0.0";
        String platform = "android";
        String environment = "production";
        String appLanguage = "es"; //Nullable
        String preferredAndroidMarket: PreferredAndroidMarket.AMAZON // or PreferredAndroidMarket.HUAWEI or PreferredAndroidMarket.OTHER
        String otherAndroidMarketUrl: 'https://someotherandroidmarket.com/app/id'// Required if preferredAndroidMarket is Other.

        AppInfo appInfo = new AppInfo(appId, appName, appVersion, platform, environment, appLanguage);

        // Optional
        String title = "Update Required.";
        String updateButtonTitle = "UPDATE";
        String laterButtonTitle = "Not Now";
        AlertDialogConfig alertDialogConfig = new AlertDialogConfig(title, updateButtonTitle, laterButtonTitle);

        AppUpgrade appUpgrade = new AppUpgrade();
        appUpgrade.checkForUpdates(this, xApiKey, appInfo, alertDialogConfig);
    }
}

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-2024 | App Upgrade | All Rights Reserved            Updated 2024-06-30 14:11:37

results matching ""

    No results matching ""