- 1. Introduction
- 2. Installation Guide
- 3. Configuration and Description
- 4. Questions or Issues
- 5. Licensing and Terms
This demo application demonstrates the usage of the HMS Scan Kit Cordova plugin.
-
Install Ionic CLI and other required tools if haven't done before.
npm install -g @ionic/cli cordova-res native-run
-
Open the demo project's root directory.
-
Install project dependencies.
npm install
-
Enable the Cordova integration.
ionic integrations enable cordova
-
Add the Android platform to the project.
ionic cordova platform add android
-
Install
HMS Scan plugin
to the project.ionic cordova plugin add @hmscore/cordova-plugin-hms-scan
-
Install HMS Scan Ionic Native wrappers
npm install @ionic-native/core @hmscore/ionic-native-hms-scan
-
Build Ionic app to generate resource files.
ionic build
-
Run the app.
ionic cordova run android --device
-
Enable the Capacitor integration.
ionic integrations enable capacitor
-
Initialize Capacitor.
npx cap init [appName] [appId]
- For more details please follow Initialize Capacitor with your app information.
-
Install
HMS Scan plugin
to the project.npm install @hmscore/cordova-plugin-hms-scan
-
Install HMS Scan Ionic Native wrappers.
npm install @ionic-native/core @hmscore/ionic-native-hms-scan
-
Build Ionic app to generate resource files.
ionic build
-
Add the Android platform to the project.
npx cap add android
-
Updates dependencies, and copy any web assets to your project.
npx cap sync
-
Open the
build.gradle
file in the<project_root>/android
directory. Add Huawei's maven repositories.buildscript { repositories { /* <Other repositories> */ maven { url 'https://developer.huawei.com/repo/' } } } /* <Other build.gradle entries> */ allprojects { repositories { /* <Other repositories> */ maven { url 'https://developer.huawei.com/repo/' } } }
-
Open the project in Android Studio and run it.
npx cap open android
Please, do not forget to add following prefix to file paths in ionic application.
- For Ionic - Cordova Runtime = "www/assets/your_file"
- For Ionic - Capacitor Runtime = "public/assets/your_file".
For example, in demo application:
// roll.html file is under assets folder directly. So that, path should be given like below.
await this.rollAdInstance.loadAd({ file: 'public/assets/roll.html' });
}
Before building the APK, configure the obfuscation configuration file to prevent the HMS Core SDK from being obfuscated.
NOTE: This step is required only if you want to minify and obfuscate your app. By default obfuscation is disabled in Cordova and Ionic apps.
The obfuscation is done by ProGuard. By default, in Cordova and Ionic apps ProGuard is disabled. Even though ProGuard is not available, ProGuard support can be added through 3rd party ProGuard plugins. If ProGuard is enabled in your project, the Huawei Cordova Scan plugin's ProGuard rules need to be added to your project. These rules are as follows:
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.hms.scan.**{*;}
-keep interface com.huawei.hms.scan.**{*;}
-keep class com.huawei.openalliance.ad.**{*;}
-repackageclasses
If you have questions about how to use HMS samples, try the following options:
- Stack Overflow is the best place for any programming questions. Be sure to tag your question with
huawei-mobile-services
. - GitHub is the official repository for these plugins, You can open an issue or submit your ideas.
- Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
- Huawei Developer Docs is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.
If you run into a bug in our samples, please submit an issue to the GitHub repository.
Huawei Scan Kit Cordova Plugin is licensed under the Apache 2.0 license.