npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hcm-admin

v0.1.4

Published

HCM Node SDK.

Downloads

8

Readme

HMS Core Push Kit (Node.js)

English | 中文

Contents

Introduction

The sample code for Node.js encapsulates the server-side APIs of Push Kit, for your reference or direct use.

The following table describes packages of Node.js sample code. | Package| Description | ---- | ----- | examples | Sample code packages. | utils | Package that provides methods for sending public network requests and for common verification. | push | Package where Push Kit server APIs are encapsulated.

Installation

Install Node.js on your device.

Run the following command in the nodejs-sdk project:

$ npm install

Run the following command:

$ npm run build

Environment Requirements

Node.js 8.13.0 or later.

Note that the Node.js sample code can be used only in the server-side or background environments that you control, including most servers and serverless platforms (both on-premise and in the cloud).

Configuration

Start configuration with the index.ts file. Create an HcmNamespace object, and call the methods in the object to perform initialization. Access different modules, such as the messaging or topic module, and call the methods in each module.

To use the functions provided by the packages in examples, set initialization and request parameters in the config.js file.

| Parameter| Description| | ---- | ----- | | AppId|App ID, which is obtained from the app information.| | AppSecret|App secret, which is obtained from the app information.| | AuthUrl|URL for Huawei OAuth 2.0 to obtain a token. For details, please refer to OAuth 2.0-based Authentication.| | PushUrl|Access address of Push Kit. For details, please refer to Downlink Message Sending.|

| Request Parameter| Description| | ---- | ----- | | TargetTopic|Name of the topic to be subscribed to, unsubscribed from, or queried.| | TargetCondition|Combined condition expression for sending a message.| | TargetToken|Token of a target device.|

Sample Code

node.js sample code uses index.ts as the entry. Call methods on object HcmNamespace: messaging and topic.

The following table lists methods in HcmNamespace. | Method | Description | | ---- | ---- | | messaging | The entry of the Messaging object, and verify the initialization input parameters. | | topic | The entry of the Topic object, and verify the initialization input parameters. |

The following table lists methods in Messaging. | Method | Description | | ---- | ---- | | send | Verify if the token needs to be updated and call the method sendRequest. | | sendRequest | Sends a message to a device. |

The following table lists methods in Topic. | Method | Description | | ---- | ---- | | subScribeTopic | Subscribe to topic. | | unSubScribeTopic | Unsubscribe topic. | | queryTopicList | Query subject list. |

1. Send an Android data message.

Code location: examples/send_data_message.js

2. Send an Android notification message.

Code location: examples/send_notify_message.js

3. Send a message by topic.

Code location: examples/send_topic_message.js

4. Send a message by conditions.

Code location: examples/send_condition_message.js

5. Send a message to a Huawei quick app.

Code location: examples/send_instance_app_message.js

6. Send a message through the WebPush agent.

Code location: examples/send_webpush_message.js

7. Send a message through the APNs agent.

Code location: examples/send_apns_message.js

8. Send a test message.

Code location: examples/send_test_message.js

Technical Support

You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers.

If you have any questions about the sample code, try the following:

  • Visit Stack Overflow, submit your questions, and tag them with huawei-mobile-services. Huawei experts will answer your questions.
  • Visit the HMS Core section in the HUAWEI Developer Forum and communicate with other developers.

If you encounter any issues when using the sample code, submit your issues or submit a pull request.

License

The sample code is licensed under Apache License 2.0.