Skip to content

极光推送Golang客户端,支持异步发送队列 https://docs.jiguang.cn/

License

Notifications You must be signed in to change notification settings

taojicai/jpush-go

 
 

Repository files navigation

文档查看

JPush Golang Client

Build Codecov ReportCard GoDoc License

快速开始

下载安装

$ go get -u -v github.com/JeffreyBool/jpush-go

创建文件 push.go

package main

import (
	"context"
	"fmt"

	"github.com/JeffreyBool/jpush-go"
)

func main() {
	jpush.Init(2,
		jpush.SetAppKey("b1ccd0dd04ec36b66c75e99f"),
		jpush.SetMasterSecret("ed431429270144d3ed53555b"),
	)

	defer jpush.Terminate()

	payload := &jpush.Payload{
		Platform:     jpush.NewPlatform().All(),
		Audience:     jpush.NewAudience().All(),
		Notification: jpush.NewNotification().SetAlert("通知测试"),
		Options:      jpush.NewOptions().SetSendNO(1),
	}
	err := jpush.Push(context.Background(), payload, func(result *jpush.PushResult, err error) {
		if err != nil {
			panic(err)
		}
		fmt.Println(result.String())
	})
	if err != nil {
		panic(err)
	}
}

编译运行

$ go build push.go
$ ./push

输出结果

{"sendno":"1","msg_id":"3866336947"}

特性

  • 支持异步推送队列
  • 自动处理频率限制
  • 自动维护cid池

MIT License

Copyright (c) 2018 JeffreyBool

About

极光推送Golang客户端,支持异步发送队列 https://docs.jiguang.cn/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Go 100.0%