|
@@ -6,12 +6,12 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// 极光推送 最大1000个用户 |
|
|
// 极光推送 最大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) |
|
|
var client = jpush.NewClient(key, secret) |
|
|
audience := &jpush.PushAudience{ |
|
|
audience := &jpush.PushAudience{ |
|
|
Alias: alias, |
|
|
Alias: alias, |
|
|
} |
|
|
} |
|
|
req := getMsg(title, content, audience, extras) |
|
|
|
|
|
|
|
|
req := getMsg(title, content, platform, audience, extras) |
|
|
result, err := client.Push(req) |
|
|
result, err := client.Push(req) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
@@ -20,10 +20,10 @@ func PushMoreUser(key, secret, title, content string, alias []string, extras map |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 广播推送 一天10次 |
|
|
// 广播推送 一天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) |
|
|
var client = jpush.NewClient(key, secret) |
|
|
audience := "all" |
|
|
audience := "all" |
|
|
req := getMsg(title, content, audience, extras) |
|
|
|
|
|
|
|
|
req := getMsg(title, content, platform, audience, extras) |
|
|
result, err := client.Push(req) |
|
|
result, err := client.Push(req) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
fmt.Println(err) |
|
|
fmt.Println(err) |
|
@@ -32,9 +32,9 @@ func PushAllUser(key, secret, title, content string, extras map[string]interface |
|
|
fmt.Println(result) |
|
|
fmt.Println(result) |
|
|
return result, nil |
|
|
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{ |
|
|
req := &jpush.PushRequest{ |
|
|
Platform: "all", |
|
|
|
|
|
|
|
|
Platform: jpush.Platform(platform), |
|
|
Audience: audience, |
|
|
Audience: audience, |
|
|
Notification: &jpush.PushNotification{ |
|
|
Notification: &jpush.PushNotification{ |
|
|
Alert: content, |
|
|
Alert: content, |
|
|