|
| 1 | +# AGC APM Cordova Demo |
| 2 | + |
| 3 | +## Contents |
| 4 | + |
| 5 | +- [1. Introduction](#1-introduction) |
| 6 | +- [2. Installation Guide](#2-installation-guide) |
| 7 | + - [2.1. Creating a Project in AppGallery Connect](#21-creating-a-project-in-appgallery-connect) |
| 8 | + - [2.2. Obtaining agconnect-services.json and agconnect-services.plist](#22-obtaining-agconnect-servicesjson-and-agconnect-servicesplist) |
| 9 | + - [2.3. Cordova](#23-cordova) |
| 10 | + - [2.3.1. iOS App Development](#231-ios-app-development) |
| 11 | + - [2.3.2. Android App Development](#232-android-app-development) |
| 12 | +- [3. Configuration and Description](#3-configuration-and-description) |
| 13 | +- [4. Development Environment](#4-development-environment) |
| 14 | +- [5. FAQs](#5-faqs) |
| 15 | +- [6. Licencing and Terms](#6-licencing-and-terms) |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## 1. Introduction |
| 20 | + |
| 21 | +This demo application demonstrates the usage of AGC App Performance Management (APM) Cordova plugin. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 2. Installation Guide |
| 26 | + |
| 27 | +Before you get started, you must register as a HUAWEI Developer and complete identity verification on the [HUAWEI Developer](https://developer.huawei.com/consumer/en/?ha_source=hms1) website. For details, please refer to [Register a HUAWEI ID](https://developer.huawei.com/consumer/en/doc/10104?ha_source=hms1). |
| 28 | + |
| 29 | +### 2.1. Creating a Project in AppGallery Connect |
| 30 | + |
| 31 | +Creating an app in AppGallery Connect is required in order to communicate with the Huawei services. To create an app, perform the following steps: |
| 32 | + |
| 33 | +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select **My projects**. |
| 34 | +2. Select your project from the project list or create a new one by clicking the **Add Project** button. |
| 35 | +3. Go to **Project settings** > **General information**, and click **Add app**. |
| 36 | + 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**. |
| 37 | +4. On the **Add app** page, enter the app information, and click **OK**. |
| 38 | + |
| 39 | +### 2.2. Obtaining agconnect-services.json and agconnect-services.plist |
| 40 | + |
| 41 | +1. Sign in to [AppGallery Connect](https://developer.huawei.com/consumer/en/service/josp/agc/index.html?ha_source=hms1) and select your project from **My Projects**. Then go to **Project settings** > **General information**. In the **App information** field, |
| 42 | + |
| 43 | + - If platform is Android, click **agconnect-services.json** button to download the configuration file. |
| 44 | + - If platform is iOS, click **agconnect-services.plist** button to download the configuration file. |
| 45 | + |
| 46 | +### 2.3. Cordova |
| 47 | + |
| 48 | +1. Install Cordova CLI. |
| 49 | + |
| 50 | + ```bash |
| 51 | + npm install -g cordova |
| 52 | + ``` |
| 53 | + |
| 54 | +2. Set preference in your Cordova project config.xml. |
| 55 | + |
| 56 | + ```xml |
| 57 | + <!--<platform name="ios">--> |
| 58 | + <preference name="deployment-target" value="11.0" /> |
| 59 | + <preference name="SwiftVersion" value="5" /> |
| 60 | + ``` |
| 61 | + |
| 62 | +3. Update the widget **`id`** property which is specified in the **`config.xml`** file. It must be same with **client > package_name** value of the **`agconnect-services.json`** and **`agconnect-services.plist`** files. |
| 63 | + |
| 64 | +4. Add the **Android** or **iOS** platform to the project if haven't done before. |
| 65 | + |
| 66 | + ```bash |
| 67 | + cordova platform add android |
| 68 | + ``` |
| 69 | + |
| 70 | + ```bash |
| 71 | + cordova platform add ios |
| 72 | + ``` |
| 73 | + |
| 74 | +5. Install `AGC APM Cordova Plugin` to the project. |
| 75 | + |
| 76 | + - Run the following command in the root directory of your project to install it through **npm**. |
| 77 | + |
| 78 | + ```bash |
| 79 | + cordova plugin add @cordova-plugin-agconnect/apm --variable APMS_DEBUG_LOG_ENABLED="true" --variable SESSIONS_SAMPLING_PERCENTAGE="1.0" --variable COLLECT_CPU_FREQUENCY_FG_MS="100" --variable COLLECT_MEMORY_FREQUENCY_FG_MS="100" --save |
| 80 | + ``` |
| 81 | + |
| 82 | +#### 2.3.1. iOS App Development |
| 83 | + |
| 84 | +1. Add **`agconnect-services.plist`** file to the app's root directory of your Xcode project. |
| 85 | +
|
| 86 | +2. Check Signing & Capabilities tab page of your Xcode project. |
| 87 | +
|
| 88 | +3. Run the application. |
| 89 | +
|
| 90 | + ```bash |
| 91 | + cordova run ios --device |
| 92 | + ``` |
| 93 | +
|
| 94 | +#### 2.3.2. Android App Development |
| 95 | +
|
| 96 | +1. Copy **`agconnect-services.json`** file to **`<project_root>/platforms/android/app`** directory your Android project. |
| 97 | +
|
| 98 | +2. Open MainActivity.java class in your **Cordova-Android project**. |
| 99 | +
|
| 100 | +3. Fields marked with red should be written in your **MainActivity.java** class. |
| 101 | +<img src=".img/MainActivity_java.png"> |
| 102 | +
|
| 103 | +4. Run the application. |
| 104 | +
|
| 105 | + ```bash |
| 106 | + cordova run android --device |
| 107 | + ``` |
| 108 | +
|
| 109 | +--- |
| 110 | +
|
| 111 | +## 3. Configuration and Description |
| 112 | +No. |
| 113 | +
|
| 114 | +--- |
| 115 | +
|
| 116 | +## 4. Development Environment |
| 117 | +You are advised to use the plug-ins in an environment that meets the following requirements. |
| 118 | +
|
| 119 | +| Software | Allowed Version Range | Description | |
| 120 | +| --------------- | --------------------- | ------------ | |
| 121 | +| cordova | 9.0.0 or later | Platform | |
| 122 | +| cordova-android | >=8.1.0 or later | Platform | |
| 123 | +| cordova-ios | 5.0.0 or later | Platform | |
| 124 | +| npm | 6.4.1 or later | Tool | |
| 125 | +
|
| 126 | +--- |
| 127 | + |
| 128 | +## 5. FAQs |
| 129 | +No. |
| 130 | +
|
| 131 | +## 6. Licencing and Terms |
| 132 | +
|
| 133 | +AGC APM Cordova Plugin is licensed under the [Apache 2.0 license](LICENCE). |
0 commit comments