Browse Source

add reverse:for v1.0.2 极光推送

tags/v1.0.2
huangjiajun 2 years ago
parent
commit
ed92b10f96
2 changed files with 7 additions and 7 deletions
  1. +6
    -6
      hdl/jg_push.go
  2. +1
    -1
      hdl/push_test.go

+ 6
- 6
hdl/jg_push.go View File

@@ -10,10 +10,10 @@ import (
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
) )


func Send(appKey, appSecret string, param md.PushParam) (string, error) {
func Send(appKey, appSecret string, param md.PushParam) (string, string, error) {


if appKey == "" || appSecret == "" { if appKey == "" || appSecret == "" {
return "", errors.New("配置未设置")
return "", "", errors.New("配置未设置")
} }
url := "https://api.jpush.cn/v3/push" url := "https://api.jpush.cn/v3/push"
var iosAlert = md.PushIosAlert{Title: param.Title, Body: param.Content} var iosAlert = md.PushIosAlert{Title: param.Title, Body: param.Content}
@@ -55,16 +55,16 @@ func Send(appKey, appSecret string, param md.PushParam) (string, error) {
} }
b, err := json.Marshal(req) b, err := json.Marshal(req)
if err != nil { if err != nil {
return "", err
return "", "", err
} }
res, err := jg_push_utils.CurlPost(url, b, headers) res, err := jg_push_utils.CurlPost(url, b, headers)
if err != nil { if err != nil {
return "", err
return "", "", err
} }
fmt.Println(string(res)) fmt.Println(string(res))
msgId := gjson.Get(string(res), "msg_id").String() msgId := gjson.Get(string(res), "msg_id").String()
if msgId == "0" || msgId == "" { if msgId == "0" || msgId == "" {
return "", err
return "", string(res), err
} }
return msgId, nil
return msgId, string(res), nil
} }

+ 1
- 1
hdl/push_test.go View File

@@ -26,5 +26,5 @@ func TestPush(t *testing.T) {
Content: "哈哈哈哈", Content: "哈哈哈哈",
Extras: extras, Extras: extras,
} }
Send("6033fc3e19543740413d19aa", "ca7db52b63f7833299042f6a", param)
Send("6033fc3e19543740413d19aa", "ca7db52b63f7833299042f6a1", param)
} }

Loading…
Cancel
Save