icecream78 / go-hms-push

HUAWEI Push Kit client library for Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

HUAWEI Push Kit client library for Golang

License:MIT License


Languages

Language:Go 100.0%