Browse Source

极光推送

master
huangjiajun 1 month ago
parent
commit
e780dc13bf
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      jPush/push.go

+ 6
- 6
jPush/push.go View File

@@ -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…
Cancel
Save