Code Monkey home page Code Monkey logo

jpush-go's Introduction

JPush Golang Client

Build Codecov ReportCard GoDoc License

快速开始

下载安装

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

创建文件 push.go

package main

import (
	"context"
	"fmt"

	"github.com/LyricTian/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 Lyric

jpush-go's People

Contributors

lyrictian avatar vikmeup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jpush-go's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.