This demo project is an example to demonstrate the features of the **AppGallery Connect Flutter Cloud Functions Kit ** Plugin.
Before you get started, you must register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.
Creating an app in AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps:
Step 1. Set an unique Application ID on the app level build gradle file located on example/android/app/build.gradle. You should also change the package names for the manifest files in the /example/android/app/src/ directory and on the MainActivity.java to match with the Application ID.
<!-- Other configurations ... -->
defaultConfig {
// Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). You may need to change the package name on AndroidManifest.xml and MainActivity.java respectively.
// The Application ID here should match with the Package Name on the AppGalleryConnect
applicationId "<Enter_your_package_name_here>" // For ex: "com.developer.cloudfunctions"
minSdkVersion 17
<!-- Other configurations ... -->
}
Step 2. Sign in to AppGallery Connect and select My projects.
Step 3. Select your project from the project list or create a new one by clicking the Add Project button.
Step 4. Go to Project Setting > General information, and click Add app. If an app exists in the project and you need to add a new one, expand the app selection area on the top of the page and click Add app.
Step 5. On the Add app page, enter the Application ID you've defined before as the Package Name here, then fill the necessary fields and click OK.
-
In AppGallery Connect, find your project, and click the app for which you want to use cloud functions.
-
Select Build and Cloud functions on the left menu and click Enable Cloud Functions service.
To create a cloud function, please refer Create a Function.
Creating a Trigger: To call a function in an app, you must create an HTTP trigger. For details, please refer to Create an HTTP Trigger. When calling a function in an app, you must transfer the identifier of an HTTP trigger. For details, please refer to Querying the Trigger Identifier
Step 1: Run the following command to update package info.
[project_path]> flutter pub get
Step 2: Run the following command to start the demo app.
[project_path]> flutter run
Before building the APK, configure obfuscation scripts to prevent the AppGallery Connect SDK from being obfuscated. If obfuscation arises, the AppGallery Connect SDK may not function properly. For more information on this topic refer to this Android developer guide.
<flutter_project>/android/app/proguard-rules. pro
-ignorewarnings
-keep class com.huawei.agconnect.**{*;}
# Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
-keep class com.huawei.hianalytics.**{*;}
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.agconnect.**{*;}
-keep class com.huawei.agc.**{*;}
-repackageclasses
<flutter_project>/android/app/build.gradle
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
// Enables code shrinking, obfuscation and optimization for release builds
minifyEnabled true
// Unused resources will be removed, resources defined in the res/raw/keep.xml will be kept.
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
AppGallery Connect Cloud Functions Kit Flutter Plugin Demo is licensed under Apache 2.0 license