Skip to content

icecream78/go-hms-push

Repository files navigation

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)
}