Sending Event Push with Huawei Ability Gallery

Yağmur Kılıç
Huawei Developers
Published in
3 min readSep 30, 2021

In This article, we will learn how to implement the — Huawei Ability Gallery “Event Push” step by step.

Event Push

After a user subscribes to a developer’s ability on a Huawei product (such as HUAWEI Assistant), when the ability has a news feed, the developer’s server pushes the feed to HUAWEI Ability Gallery as an event through the event notification API. In this article, We will work on an “event push” use case.

Events to be pushed are classified into user events and common events, based on the relevance between events and users.

Common Events

This type uses for sending notifications to all users using and subscribing to the application. Account Binding is not required to push COMMON events. such as, products that the Shopping app recommends to all users.

User Events

This type uses for notifying specified users through OpenID. Account Binding is mandatory to send notifications to the specified users.

If everybody is ready, let’s get started :)

Implementation

The event notification process consists of two phases in total. The first phase is card design and configuration. The second phase is backend development for sending events. You can review this article to learn how to implement the first phase.

Project

In this article, we will implement an event push API on a bank application. The scheme below will help you better understand the “event push” example use case in my project.

As you can see from the flow chart above, if the money transfer is successful, we send an event message to the HAG server.

Backend Implementation Steps to Send Event Notification

  1. Develop an account binding API, which is required to push user events. I have discussed the account binding step in my previous article — Account Binding Solution 1.
  2. Apply for an app ID on HUAWEI Developer, and obtain an app-level access token (AT).

Server Url: https://login.cloud.huawei.com/oauth2/v2/token

Content-Type: application/x-www-form-urlencoded

Method: POST

3. Develop an event push API to push users’ ability feeds to HUAWEI Ability Gallery as events.

Server Url: https://hag-eu.cloud.huawei.com/open-ability/v1

URL: /service-events/notify

Method: POST

Note: A developer’s server uses this API to send an ability event notification to a user.

4. Develop an API for the card to interact with HUAWEI Ability Gallery and call event push API.

Conclusion

I hope this article helps you better understand Huawei Ability Gallery — Event Push process.

Thanks for reading. If you have a question, don’t hesitate to contact me.

--

--