瀏覽代碼

极光推送

master
huangjiajun 3 天之前
父節點
當前提交
e780dc13bf
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. +6
    -6
      jPush/push.go

+ 6
- 6
jPush/push.go 查看文件

@@ -6,12 +6,12 @@ import (
)

// 极光推送 最大1000个用户
func PushMoreUser(key, secret, title, content string, alias []string, extras map[string]interface{}) (map[string]interface{}, error) {
func PushMoreUser(key, secret, title, content string, platform string, alias []string, extras map[string]interface{}) (map[string]interface{}, error) {
var client = jpush.NewClient(key, secret)
audience := &jpush.PushAudience{
Alias: alias,
}
req := getMsg(title, content, audience, extras)
req := getMsg(title, content, platform, audience, extras)
result, err := client.Push(req)
if err != nil {
return nil, err
@@ -20,10 +20,10 @@ func PushMoreUser(key, secret, title, content string, alias []string, extras map
}

// 广播推送 一天10次
func PushAllUser(key, secret, title, content string, extras map[string]interface{}) (map[string]interface{}, error) {
func PushAllUser(key, secret, title, content string, platform string, extras map[string]interface{}) (map[string]interface{}, error) {
var client = jpush.NewClient(key, secret)
audience := "all"
req := getMsg(title, content, audience, extras)
req := getMsg(title, content, platform, audience, extras)
result, err := client.Push(req)
if err != nil {
fmt.Println(err)
@@ -32,9 +32,9 @@ func PushAllUser(key, secret, title, content string, extras map[string]interface
fmt.Println(result)
return result, nil
}
func getMsg(title, content string, audience interface{}, extras map[string]interface{}) *jpush.PushRequest {
func getMsg(title, content string, platform string, audience interface{}, extras map[string]interface{}) *jpush.PushRequest {
req := &jpush.PushRequest{
Platform: "all",
Platform: jpush.Platform(platform),
Audience: audience,
Notification: &jpush.PushNotification{
Alert: content,


Loading…
取消
儲存