Bladeren bron

add reverse:for v1.0.2 极光推送

tags/v1.0.2
huangjiajun 2 jaren geleden
bovenliggende
commit
ed92b10f96
2 gewijzigde bestanden met toevoegingen van 7 en 7 verwijderingen
  1. +6
    -6
      hdl/jg_push.go
  2. +1
    -1
      hdl/push_test.go

+ 6
- 6
hdl/jg_push.go Bestand weergeven

@@ -10,10 +10,10 @@ import (
"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 == "" {
return "", errors.New("配置未设置")
return "", "", errors.New("配置未设置")
}
url := "https://api.jpush.cn/v3/push"
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)
if err != nil {
return "", err
return "", "", err
}
res, err := jg_push_utils.CurlPost(url, b, headers)
if err != nil {
return "", err
return "", "", err
}
fmt.Println(string(res))
msgId := gjson.Get(string(res), "msg_id").String()
if msgId == "0" || msgId == "" {
return "", err
return "", string(res), err
}
return msgId, nil
return msgId, string(res), nil
}

+ 1
- 1
hdl/push_test.go Bestand weergeven

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

Laden…
Annuleren
Opslaan