Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.23 KB

README.md

File metadata and controls

54 lines (37 loc) · 1.23 KB

go-hms-push

GoDoc

This project was reworked version of Huawei demo pack.

Golang client library for APIs of the HUAWEI Push Kit server. Implemented only HTTP client.

More information on Huawei HMS Core

Getting Started

To install go-hms-push, use go get:

go get github.com/icecream78/go-hms-push

Sample Usage

Here is a simple example illustrating how to use HMS push library:

package main

import (
	"context"
	"log"

	hms "github.com/icecream78/go-hms-push"
)

const (
	appId     string = "xxxxxx"
	appSecret string = "xxxxxx"
	clientToken  string = "xxxxxx"
)

func main() {
	client, err := hms.NewHuaweiClient(appId, appSecret)
	if err != nil {
		log.Fatal(err)
	}

	msg := hms.GetDefaultAndroidNotificationMessage([]string{clientToken})

	resp, err := client.SendMessage(context.Background(), msg)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%#v\n", resp)
}