HMS In-App Update API
Introduction
You have a published app on Huawei AppGallery and you submitted new version recently. But most of users not updated yet. Maybe these users turned off automaticly updates or update notifications. Who knows?
If you want give information about new version is available to your users when opened your app, you can use HMS In-app update API so easily.
How we can use this API? Let’s learn.
Before starting
- You must have a published app on AppGallery
- Add the AppGallery Connect configuration file of your app to your project.
- Configure the Maven repository address for the HMS Core SDK.
Add implementation on your gradle file
dependencies {
implementation 'com.huawei.hms:hwid:{version}'
implementation 'com.huawei.hms:hianalytics:{version}'
…
implementation 'com.huawei.hms:appservice:{version}'
}
Note: appservice indicates the joint operations app SDK. Replace {version} with the latest version number 5.0.4.303. Note that you cannot integrate the joint operations app SDK together with the Game Service SDK. Otherwise, resource conflicts may occur
Don’t forget add the
apply plugin: 'com.huawei.agconnect'
under apply plugin: ‘com.android.application’ in the file header
Configuring Obfuscation Scripts
The obfuscation script file for Android Studio is proguard-rules.pro and that for Eclipse is proguard-project.txt.
- Open the obfuscation configuration file of your project.
- Add configurations to exclude the HMS Core SDK from obfuscation.
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
-keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
-keep class com.huawei.hms.analytics.HiAnalytics{*;}
3. If you are using AndResGuard, add its trustlist to the obfuscation configuration file.
"R.string.agc*",
"R.string.hms*",
"R.string.connect_server_fail_prompt_toast",
"R.string.getting_message_fail_prompt_toast",
"R.string.no_available_network_prompt_toast",
"R.string.third_app_*",
"R.layout.hms*",
"R.drawable.upsdk*",
"R.color.upsdk*",
"R.dimen.upsdk*",
"R.style.upsdk*",
"R.id.scroll_layout",
"R.id.divider",
"R.id.name_textview",
"R.id.version_textview",
"R.id.appsize_textview",
"R.id.allsize_textview",
"R.id.content_textview",
"R.id.third_app_dl_progress_text",
"R.id.cancel_bg",
"R.id.third_app_dl_progressbar",
"R.id.upsdk*",
"R.string.upsdk*",
"R.layout.upsdk*"
Development Process
- When we want to check for update you have to start with JosApps.getAppUpdateClient to request to initialize the AppUpdateClient instance
2. Then, we have to use checkAppUpdate function in client like this;
3. Lastly, we have to listen callbacks and show popup for users
Conclusion
In this document, I tried to explain how we can check update by in-app. That is so easy. Hope this is helpful for you.