- 1. Introduction
- 2. Installation Guide
- 3. Method Definitions
- 4. Configuration and Description
- 5. Licensing and Terms
This demo application demonstrates the usage of AGC Cloud Functions Cordova 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:
- Sign in to AppGallery Connect and select My projects.
- Select your project from the project list or create a new one by clicking the Add Project button.
- Go to Project settings > 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.
- On the Add app page, enter the app information, and click OK.
-
Sign in to AppGallery Connect and select your project from My Projects. Then go to Project settings > General information. In the App information field,
- If platform is Android, click agconnect-services.json button to download the configuration file.
- If platform is iOS, click agconnect-services.plist button to download the configuration file.
Cloud Functions is still in Beta state. To use Cloud Functions, send an application email to [email protected] to apply for the service.
Set your email title in the following format: [Cloud Functions]-[Company name]-[Developer account ID]-[Project ID]. For details about how to query the developer account ID and project ID, please refer to Querying the Developer Account ID and Project ID.
Huawei operation personnel will reply within 1 to 3 working days.
This email address is used only to process AppGallery Connect service provisioning applications. Do not send other consultations to this email address.
-
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
-
Install Cordova CLI.
npm install -g cordova
-
Create a new Cordova project or use existing Cordova project.
- To create new Cordova project, you can use
cordova create path [id [name [config]]] [options]
command. For more details please follow CLI Reference - Apache Cordova.
- To create new Cordova project, you can use
-
Update the widget
id
property which is specified in theconfig.xml
file. It must be same with client > package_name value of theagconnect-services.json
andagconnect-services.plist
files. -
Update the '<set_triggerIdentifier>' parameter which is specified in the
<project_root>/www/js/index.js
file. -
Check preference in your Cordova project config.xml.
<!--platform iOS--> <preference name="deployment-target" value="11.0" /> <preference name="SwiftVersion" value="5" />
-
Add the Android or iOS platform to the project if haven't done before.
cordova platform add android
cordova platform add ios
-
Install
AGC Cloud Functions Cordova Plugin
to the project.
- Run the following command in the root directory of your project to install it through npm.
cordova plugin add @cordova-plugin-agconnect/cloudfunctions
-
Add
agconnect-services.plist
file to the app's root directory of your Xcode project. -
Run the application.
cordova run ios --device
-
Copy
agconnect-services.json
file to<project_root>/platforms/android/app
directory your Android project. -
Run the application.
cordova run android --device
Method | Return Type | Description |
---|---|---|
call() | void |
Calls a function without input parameters. |
callWithParam() | void |
Calls a function with input parameters. |
No.
AGC Cloud Functions Cordova Plugin is licensed under the Apache 2.0 license.