华为推送服务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.  ̄へ ̄
RequestAccessToken
SingleSend
BatchSend
PsSingleSend
PsBatchSend
QueryMsgResult
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
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.