|
7 | 7 | * [Installation](#installation)
|
8 | 8 | * [Configuration ](#configuration )
|
9 | 9 | * [Supported Environments](#supported-environments)
|
10 |
| - * [Sample Code](# Sample Code) |
| 10 | + * [Sample Code](#sample-code) |
11 | 11 | * [License](#license)
|
12 | 12 |
|
13 | 13 |
|
14 | 14 | ## Introduction
|
15 | 15 |
|
16 |
| - Python sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs about quick access |
17 |
| - to HUAWEI Push Kit for your reference or usage. |
| 16 | +Python sample code encapsulates APIs of the HUAWEI Push Kit server. It provides many sample programs about quick access to HUAWEI Push Kit for your reference or usage. |
18 | 17 |
|
19 |
| - The following table describes packages of Python sample code. |
| 18 | +The following table describes packages of Python sample code. |
20 | 19 |
|
21 |
| - ------------------------------------------------------------------------------------- |
22 |
| - Package | Description |
23 |
| - ---------- | ------------------------------------------------------------------ |
24 |
| - examples | Sample code packages. Each package can run independently. |
25 |
| - ---------- | ------------------------------------------------------------------ |
26 |
| - push_admin | Package where APIs of the HUAWEI Push Kit server are encapsulated. |
27 |
| - ------------------------------------------------------------------------------------- |
| 20 | +| Package | Description | |
| 21 | +| ---------- | ------------| |
| 22 | +| examples | Sample code packages. Each package can run independently.| |
| 23 | +| push_admin | Package where APIs of the HUAWEI Push Kit server are encapsulated.| |
28 | 24 |
|
29 | 25 | ## Installation
|
30 | 26 |
|
31 |
| - To install pushkit-python-sample, you should extract the compressed ZIP file, execute the following command in the unzipped |
32 |
| - directory: |
33 |
| - ``` |
34 |
| - python setup.py install |
35 |
| - ``` |
| 27 | +To install pushkit-python-sample, you should extract the compressed ZIP file, execute the following command in the unzipped directory: |
| 28 | +``` |
| 29 | +python setup.py install |
| 30 | +``` |
36 | 31 |
|
37 | 32 | ## Supported Environments
|
38 |
| - For pushkit-python-sample, We currently support Python 2.7 and JetBrains PyCharm are recommended. |
| 33 | +For pushkit-python-sample, We currently support Python 2.7 and JetBrains PyCharm are recommended. |
39 | 34 |
|
40 | 35 |
|
41 | 36 | ## Configuration
|
42 |
| - The following table describes parameters of the initialize_app method. |
| 37 | +The following table describes parameters of the initialize_app method. |
43 | 38 |
|
44 |
| - -------------------------------------------------------------------------------------------- |
45 |
| - Parameter | Description |
46 |
| - ------------- | ------------------------------------------------------------------------- |
47 |
| - appid | App ID, which is obtained from app information. |
48 |
| - ------------- | ------------------------------------------------------------------------- |
49 |
| - appsecret | Secret access key of an app, which is obtained from app information. |
50 |
| - ------------- | ------------------------------------------------------------------------- |
51 |
| - token_server | URL for the Huawei OAuth 2.0 service to obtain a token, please refer to Generating an App-Level Access Token. |
52 |
| - ------------- | -------------------------------------------------------------------------- |
53 |
| - push_open_url | URL for accessing HUAWEI Push Kit, please refer to Sending Messages. |
54 |
| - --------------------------------------------------------------------------------------------- |
| 39 | +| Parameter | Description | |
| 40 | +| ------------- | ------------------------------------------------------------------------- | |
| 41 | +| appid | App ID, which is obtained from app information. | |
| 42 | +| appsecret | Secret access key of an app, which is obtained from app information. | |
| 43 | +| token_server | URL for the Huawei OAuth 2.0 service to obtain a token, please refer to [Generating an App-Level Access Token](https://developer.huawei.com/consumer/en/doc/development/parts-Guides/generating_app_level_access_token). | |
| 44 | +| push_open_url | URL for accessing HUAWEI Push Kit, please refer to [Sending Messages](https://developer.huawei.com/consumer/en/doc/development/HMS-References/push-sendapi).|| |
55 | 45 |
|
56 | 46 |
|
57 | 47 | ## Sample Code
|
58 |
| - Download Python sample code in Downloading Server Sample Code. |
| 48 | +Download Python sample code in Downloading Server Sample Code. |
59 | 49 |
|
60 | 50 |
|
61 |
| - Python sample code uses the Messaging structure in the push_admin package as the entry. Each method in the Messaging |
62 |
| - structure calls an API of the HUAWEI Push Kit server. |
| 51 | +Python sample code uses the Messaging structure in the push_admin package as the entry. Each method in the Messaging |
| 52 | +structure calls an API of the HUAWEI Push Kit server. |
63 | 53 |
|
64 |
| - The following table describes methods in the Messaging structure. |
| 54 | +The following table describes methods in the Messaging structure. |
65 | 55 |
|
66 |
| - ----------------------------------------------------------------------------- |
67 |
| - Method | Description |
68 |
| - ----------------- | --------------------------------------------------- |
69 |
| - send_message | Sends a message to a device. |
70 |
| - ----------------- | --------------------------------------------------- |
71 |
| - subscribe_topic | Subscribes to a topic. |
72 |
| - ----------------- | --------------------------------------------------- |
73 |
| - unsubscribe_topic | Unsubscribes from a topic. |
74 |
| - ----------------- | --------------------------------------------------- |
75 |
| - list_topics | Queries the list of topics subscribed by a device. |
76 |
| - ----------------- | --------------------------------------------------- |
77 |
| - initialize_app | Initializes the configuration parameters. |
78 |
| - ----------------------------------------------------------------------------- |
| 56 | +| Method | Description |
| 57 | +| ----------------- | --------------------------------------------------- | |
| 58 | +| send_message | Sends a message to a device. | |
| 59 | +| subscribe_topic | Subscribes to a topic. | |
| 60 | +| unsubscribe_topic | Unsubscribes from a topic. | |
| 61 | +| list_topics | Queries the list of topics subscribed by a device. | |
| 62 | +| initialize_app | Initializes the configuration parameters. | |
79 | 63 |
|
80 | 64 |
|
81 |
| - 1) Send an Android data message. |
82 |
| - Code location: examples/send_data_message.py |
| 65 | +1) Send an Android data message. |
| 66 | +Code location: examples/send_data_message.py |
83 | 67 |
|
84 |
| - 2) Send an Android notification message. |
85 |
| - Code location: examples/send_notify_message.py |
| 68 | +2) Send an Android notification message. |
| 69 | +Code location: examples/send_notify_message.py |
86 | 70 |
|
87 |
| - 3) Send a message by topic. |
88 |
| - Code location: examples/send_topic_message.py |
| 71 | +3) Send a message by topic. |
| 72 | +Code location: examples/send_topic_message.py |
89 | 73 |
|
90 |
| - 4) Send a message by conditions. |
91 |
| - Code location: examples/send_condition_message.py |
| 74 | +4) Send a message by conditions. |
| 75 | +Code location: examples/send_condition_message.py |
92 | 76 |
|
93 |
| - 5) Send a message to a Huawei quick app. |
94 |
| - Code location: examples/send_instance_app_message.py |
| 77 | +5) Send a message to a Huawei quick app. |
| 78 | +Code location: examples/send_instance_app_message.py |
95 | 79 |
|
96 |
| - 6) Send a message through the WebPush agent. |
97 |
| - Code location: examples/send_webpush_message.py |
| 80 | +6) Send a message through the WebPush agent. |
| 81 | +Code location: examples/send_webpush_message.py |
98 | 82 |
|
99 |
| - 7) Send a message through the APNs agent. |
100 |
| - Code location: examples/send_apns_message.py |
| 83 | +7) Send a message through the APNs agent. |
| 84 | +Code location: examples/send_apns_message.py |
101 | 85 |
|
102 |
| - 8) Send a test message. |
103 |
| - Code location: examples/send_test_message.py |
| 86 | +8) Send a test message. |
| 87 | +Code location: examples/send_test_message.py |
104 | 88 |
|
105 | 89 | ## License
|
106 | 90 |
|
107 |
| - pushkit Python sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 91 | +pushkit Python sample is licensed under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0). |
0 commit comments