Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.4 KB

README.md

File metadata and controls

42 lines (32 loc) · 1.4 KB

hms-push

华为推送服务HMS版
A simple, fast HMS Huawei PUSH in Golang

This is an updated version of yilee's code (https://github.com/yilee/huawei-push), but specific to the new Huawei PUSH (HMS).

HMS promises us a higher delivery rate, a smaller client-SDK, less battery-consumption, and a BULLSHIT documentation.  ̄へ ̄

APIs Supported:

RequestAccessToken
SingleSend
BatchSend
PsSingleSend
PsBatchSend
QueryMsgResult

Usage

go get github.com/terry-xiaoyu/hms-push

// create a client
testClient := NewClient(testClientID, testClientSecret)

// the message body
message := "This is a silent notification to a single device."

// create a silent notification towards a single device
// and set the time to live to 300 seconds
notif := NewSingleNotification(testDeviceToken, message).SetTimeToLive(300)
result, err := testClient.SendPush(context.Background(), notif)
if err != nil {
    panic(fmt.Sprintf("Push failed! Error: %v", err))
}
fmt.Println("Push success, Result:", result)

More examples can be got from client_test.go

TO DO

A production ready HMS provider will come soon.
It will uses a simple Redis LIST as its input queue, TOML based config file, Metrics and Logs.