All Products
Search
Document Center

Quick start

Last Updated: Mar 24, 2021

This topic describes how to add the Upgrade SDK related to the release management. After adding the SDK and complete necessary configurations, you can release a new version of an App is released in the mPaaS console, and the client can detect the new version through the upgrade API and remind users to download and upgrade.

Currently, Upgrade SDK supports access through Native AAR, mPaaS Inside and Portal & Bundle.

The complete access process mainly includes the following 4 steps:

  1. Add SDK
  2. Configure project
  3. Initialize mPaaS (only required for Native AAR and mPaaS Inside)
  4. Check for update

Prerequisites

Add SDK

Native AAR mode

Follow the instructions in AAR component management to install the UPGRADE component in the project through Component management (AAR).

mPaaS Inside mode

Install the UPGRADE component in the project through Component management (AAR).

Fore more information, see Manage component dependencies > Add/delete component dependencies.

Componentized access mode

Install the UPGRADE component in the Portal and Bundle projects through Component management (AAR).

Fore more information, see Manage component dependencies > Add/delete component dependencies.

Configure project

Configure AndroidManifest

  1. Add the following permissions in the AndroidManifest.xml file.

    1. <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  2. Create the file_paths.xml file in the src/main/res/xml directory in the main module of the Portal project with the following content:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <resources>
    3. <paths>
    4. <external-files-path
    5. name="download"
    6. path="com.alipay.android.phone.aliupgrade/downloads" />
    7. <external-path
    8. name="download_sdcard"
    9. path="ExtDataTunnel/files/com.alipay.android.phone.aliupgrade/downloads" />
    10. </paths>
    11. </resources>
  3. Add the following configuration in the AndroidManifest.xml file:
    1. <provider
    2. android:name="android.support.v4.content.FileProvider"
    3. android:authorities="${applicationId}.fileprovider"
    4. android:exported="false"
    5. android:grantUriPermissions="true">
    6. <meta-data
    7. android:name="android.support.FILE_PROVIDER_PATHS"
    8. android:resource="@xml/file_paths" />
    9. </provider>

Add resources

Note: If you access the UPGRADE SDK through mPaaS Inside or Native AAR, you need to add the following resources to your App, otherwise, the upgrade component will not work. Click here to get the resource file.

Merge the content of strings.xml, styles.xml, and colors.xml under the values directory.

Initialize mPaaS

If you access the UPGRADE SDK through Native AAR or mPaaS Inside, you must initialize mPaaS.

Add the following codes in the object Application:

  1. public class MyApplication extends Application {
  2. @Override
  3. protected void attachBaseContext(Context base) {
  4. super.attachBaseContext(base);
  5. // Set mPaaS initialization callback
  6. QuinoxlessFramework.setup(this, new IInitCallback() {
  7. @Override
  8. public void onPostInit() {
  9. // This callback indicates that mPaaS initialization has been done, and relevant mPaaS calls can be performed here
  10. }
  11. });
  12. }
  13. @Override
  14. public void onCreate() {
  15. super.onCreate();
  16. // Initialize mPaaS
  17. QuinoxlessFramework.init();
  18. }
  19. }

Check for update

Quickly check for an update, and only the checking result is returned.

  1. MPUpgrade mMPUpgrade = new MPUpgrade();
  2. // The synchronization method, which is called in a subthread.
  3. int result = mMPUpgrade.fastCheckHasNewVersion();
  4. if (result == UpgradeConstants.HAS_NEW_VERSION) {
  5. // New version available
  6. } else if (result == UpgradeConstants.HAS_NO_NEW_VERSION) {
  7. // No new version available
  8. } else if (result == UpgradeConstants.HAS_SOME_ERROR) {
  9. // Error
  10. }