HMS PushKit Python Severdemo
English | 中文
Table of Contents
Introduction
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.
The following table describes packages of Python sample code.
| Package | Description |
|---|---|
| examples | Sample code packages. Each package can run independently. |
| push_admin | Package where APIs of the HUAWEI Push Kit server are encapsulated. |
Installation
To install pushkit-python-sample, you should extract the compressed ZIP file, execute the following command in the unzipped directory:
python setup.py install
Supported Environments
For pushkit-python-sample, We currently support Python 2.7/3.7 and JetBrains PyCharm are recommended.
Configuration
The following table describes parameters of the initialize_app method.
| Parameter | Description |
|---|---|
| appid | App ID, which is obtained from app information. |
| appsecret | Secret access key of an app, which is obtained from app information. |
| token_server | URL for the Huawei OAuth 2.0 service to obtain a token, please refer to Generating an App-Level Access Token. |
| push_open_url | URL for accessing HUAWEI Push Kit, please refer to Sending Messages. |
Sample Code
Python sample code uses the Messaging structure in the push_admin package as the entry. Each method in the Messaging structure calls an API of the HUAWEI Push Kit server.
The following table describes methods in the Messaging structure.
| Method | Description |
|---|---|
| send_message | Sends a message to a device. |
| subscribe_topic | Subscribes to a topic. |
| unsubscribe_topic | Unsubscribes from a topic. |
| list_topics | Queries the list of topics subscribed by a device. |
| initialize_app | Initializes the configuration parameters. |
-
Send an Android data message. Code location: examples/send_data_message.py
-
Send an Android notification message. Code location: examples/send_notify_message.py
-
Send a message by topic. Code location: examples/send_topic_message.py
-
Send a message by conditions. Code location: examples/send_condition_message.py
-
Send a message to a Huawei quick app. Code location: examples/send_instance_app_message.py
-
Send a message through the WebPush agent. Code location: examples/send_webpush_message.py
-
Send a message through the APNs agent. Code location: examples/send_apns_message.py
-
Send a test message. Code location: examples/send_test_message.py
Libraries
| Library | Site |
|---|---|
| requests | https://requests.readthedocs.io/en/master/ |
| six | https://six.readthedocs.io/ |
License
pushkit Python sample is licensed under the Apache License, version 2.0.
Metadata
Release files for python-huawei-push-admin 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_huawei_push_admin-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for python_huawei_push_admin-1.0.0-py3-none-any.whl |
Release files / python_huawei_push_admin-1.0.0-py3-none-any.whl
| Download URL | python_huawei_push_admin-1.0.0-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e82dce87e9a94f36ebc15db336e86b69e4699be548b9142656b926ec63895b31
|
|
BLAKE2b-256 checksum How to use checksums |
447bd4f5dc46f52574121a7e2d2ba17335c5f16b813be36c412307b3505235fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for python-huawei-push-admin 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.