zhangjinkun 7 years ago
parent
commit
8295e482bc
1 changed files with 7 additions and 1 deletions
  1. 7 1
      golang/src/jgpush/jgpush.go

+ 7 - 1
golang/src/jgpush/jgpush.go

@@ -61,6 +61,9 @@ func JgpushNc(alert, title, infotype string, ids []string, extras map[string]int
 		"options":      temp.Options,
 		//"message":      temp.Message,
 	}
+	if isbroadcast {
+		sendcon["audience"] = "all"
+	}
 	bs, _ := json.Marshal(sendcon)
 	req, _ := http.NewRequest("POST", Jgconfig.Pushurl, strings.NewReader(string(bs)))
 	req.Header.Add("Content-Type", "application/json")
@@ -99,6 +102,9 @@ func JgpushMsg(msg_title, msg_con, msg_type string, ids []string, extras map[str
 		"options":  temp.Options,
 		"message":  temp.Message,
 	}
+	if isbroadcast {
+		sendcon["audience"] = "all"
+	}
 	bs, _ := json.Marshal(sendcon)
 	req, _ := http.NewRequest("POST", Jgconfig.Pushurl, strings.NewReader(string(bs)))
 	req.Header.Add("Content-Type", "application/json")
@@ -157,7 +163,7 @@ func JgpushNcAndMsg(alert, title, infotype string, msg_title, msg_con, msg_type
 	req.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(Jgconfig.Appid+":"+Jgconfig.AppSecret)))
 	resp, err := http.DefaultClient.Do(req)
 	if err != nil {
-		log.Println("Jgpush", err.Error())
+		log.Println("JgpushNcAndMsg", err.Error())
 	} else {
 		bs, _ := ioutil.ReadAll(resp.Body)
 		resp.Body.Close()