Skip to content

Commit f1b5810

Browse files
author
mayism
committed
cordova demo/update
1 parent b9283fd commit f1b5810

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3371
-1253
lines changed

apm/.img/MainActivity_java.png

184 KB
Loading

authservice/LICENSE apm/LICENCE

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
3737
You must give any other recipients of the Work or Derivative Works a copy of this License; and
3838
You must cause any modified files to carry prominent notices stating that You changed the files; and
3939
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40-
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
40+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
4141

4242
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
4343
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

apm/README.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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).

apm/config.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<widget id="<package_name>" version="1.0.0" xmlns="http://www.w3.org/ns/widgets">
3+
<name>AGCAPMDemo</name>
4+
<description>
5+
A sample application that demonstrates AGC APM Service Plugin features on Cordova.
6+
</description>
7+
<content src="index.html"/>
8+
<plugin name="cordova-plugin-whitelist" spec="1"/>
9+
<access origin="*"/>
10+
<allow-intent href="http://*/*"/>
11+
<allow-intent href="https://*/*"/>
12+
<allow-intent href="tel:*"/>
13+
<allow-intent href="sms:*"/>
14+
<allow-intent href="mailto:*"/>
15+
<allow-intent href="geo:*"/>
16+
<platform name="android">
17+
<allow-intent href="market:*"/>
18+
</platform>
19+
<platform name="ios">
20+
<allow-intent href="itms:*"/>
21+
<allow-intent href="itms-apps:*"/>
22+
<preference name="deployment-target" value="11.0" />
23+
<preference name="SwiftVersion" value="5" />
24+
</platform>
25+
</widget>

apm/package.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "cordova-agc-apm-demo",
3+
"displayName": "AGCAPMDemo",
4+
"version": "1.0.0",
5+
"author": "agc",
6+
"description": "A demo application which shows the usage of @cordova-plugin-agconnect/apm",
7+
"homepage": "https://developer.huawei.com/consumer/en/agconnect/",
8+
"license": "Apache-2.0",
9+
"licenseFilename": "LICENCE",
10+
"readmeFilename": "README.md",
11+
"main": "./www/js/index.js",
12+
"keywords": [
13+
"ecosystem:cordova",
14+
"apm",
15+
"huawei-apm",
16+
"agc-apm"
17+
],
18+
"devDependencies": {
19+
"cordova-plugin-whitelist": "^1.3.5"
20+
},
21+
"cordova": {
22+
"plugins": {
23+
"cordova-plugin-whitelist": {}
24+
},
25+
"platforms": [
26+
]
27+
},
28+
"files": [
29+
"./www",
30+
"config.xml",
31+
"LICENCE",
32+
"package.json",
33+
"README.md",
34+
".img"
35+
]
36+
}

apm/www/css/index.css

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License")
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
button {
18+
width: 90%;
19+
height: 35px;
20+
margin: 5px;
21+
border-radius: 4px;
22+
background: #0066ff;
23+
font-size: 20px;
24+
}
25+
26+
.container {
27+
text-align: center;
28+
position: absolute;
29+
left: 0;
30+
right: 0;
31+
top: 7%;
32+
font-size: 20px;
33+
}
34+
35+
select {
36+
width: 90%;
37+
border: solid 2px #9ab7d3;
38+
height: 35px;
39+
border-radius: 4px;
40+
margin: auto;
41+
margin-top: 3%;
42+
font-size: 20px;
43+
}
44+
45+
input {
46+
border: solid 2px #9ab7d3;
47+
width: 90%;
48+
height: 35px;
49+
margin: auto;
50+
margin-top: 10px;
51+
border-radius: 4px;
52+
}
53+
54+
p {
55+
text-align: left;
56+
padding-left: 10px;
57+
padding-top: 10px;
58+
}
59+
60+
.info p {
61+
color: black;
62+
}
63+
64+
.info {
65+
border: solid 2px #9ab7d3;
66+
width: 90%;
67+
height: auto;
68+
border-radius: 4px;
69+
padding-left: 15px;
70+
padding-bottom: 2px;
71+
}
72+
73+
#main {
74+
border: solid 1px gray;
75+
border-top: transparent;
76+
}

apm/www/index.html

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<!--
3+
Copyright 2021. Huawei Technologies Co., Ltd. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License")
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<html>
18+
19+
<head>
20+
<meta charset="utf-8">
21+
<!--
22+
Customize this policy to fit your own app's needs. For more guidance, see:
23+
https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
24+
Some notes:
25+
* gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
26+
* https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
27+
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
28+
* Enable inline JS: add 'unsafe-inline' to default-src
29+
-->
30+
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
31+
<link rel="stylesheet" href="css/index.css">
32+
<title>Cordova AGC APM</title>
33+
</head>
34+
35+
<body>
36+
<div class="container">
37+
<div id="main">
38+
<h1>Cordova AGC APM</h1>
39+
<div>
40+
<!--APMS-->
41+
<button id="enableCollection" type="button">enableCollection
42+
</button>
43+
<button id="disableCollection" type="button">disableCollection
44+
</button>
45+
<button id="enableAnrMonitor" type="button">enableAnrMonitor
46+
</button>
47+
<button id="setUserIdentifier" type="button">setUserIdentifier
48+
</button>
49+
<button id="addCustomTrace" type="button">addCustomTrace
50+
</button>
51+
52+
<!--CustomTrace-->
53+
<h6>CustomTrace</h6>
54+
<button id="testCustomTrace" type="button">TestCustomTrace
55+
</button>
56+
<button id="ct_getTraceProperties" type="button">CustomTrace_getTraceProperties
57+
</button>
58+
59+
<!--NetworkMeasure-->
60+
<h6>NetworkMeasure</h6>
61+
<button id="testNetworkMeasure" type="button">TestNetworkMeasure
62+
</button>
63+
<button id="nm_getProperties" type="button">NetworkMeasure_getProperties
64+
</button>
65+
</div>
66+
67+
</div>
68+
</div>
69+
<script type="text/javascript" src="cordova.js"></script>
70+
<script type="text/javascript" src="js/index.js"></script>
71+
</body>
72+
73+
</html>

0 commit comments

Comments
 (0)