From 2b77ad0e1f407903d85c3b7bdaae0022c4ec9bc3 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 08 九月 2020 14:54:00 +0800 Subject: [PATCH] fix push bug --- service/msgPush.go | 3 +++ controllers/car.go | 29 ++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/controllers/car.go b/controllers/car.go index 9f50298..9b269d3 100644 --- a/controllers/car.go +++ b/controllers/car.go @@ -45,7 +45,7 @@ go func() { t := time.Now().Format("2006-01-02 15:04:05") message := fmt.Sprintf("%s 鍓╀綑杞︿綅锛�%d涓�", t, left) - b, e, aliasArr := service.PushByAlias("鑲茶嫳涓鍋滆溅", message, false) + b, e, aliasArr := service.PushByAlias("鍓╀綑杞︿綅鎻愰啋", message, false) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -103,7 +103,7 @@ func nightPush(curTimes int){ message := fmt.Sprintf("%s 璇峰敖蹇┒鍑哄仠杞﹀満", time.Now().Format("2006-01-02 15:04:05")) - b, e, aliasArr,carOwnNames := service.NightPush("鑲茶嫳涓鍋滆溅", message) + b, e, aliasArr,carOwnNames := service.NightPush("娓╅Θ鎻愮ず", message) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -123,8 +123,8 @@ //灏嗗叿浣撶殑杞︿富淇℃伅鎺ㄩ�佺粰绠$悊鍛� if carOwnNames != nil && len(carOwnNames) >0 { //鑾峰彇杞︿富濮撳悕 - managerMsg := fmt.Sprintf("%s 鏈┒绂昏溅涓�: %s", time.Now().Format("2006-01-02 15:04:05"), strings.Join(carOwnNames, " ")) - mb,me, managerArr := service.Push2Manager("鑲茶嫳涓鍋滆溅", managerMsg) + managerMsg := strings.Join(carOwnNames, " ") + mb,me, managerArr := service.Push2Manager(fmt.Sprintf("%s 鏈┒绂昏溅杈�", time.Now().Format("2006-01-02 15:04:05")), managerMsg) mLogE := models.Log{ Id: uuid.NewV4().String(), CreateTime: time.Now().Format("2006-01-02 15:04:05"), @@ -213,7 +213,7 @@ func (c *CarController) TestPush() { left := getSpaceLeft() message := fmt.Sprintf("%s 鍓╀綑杞︿綅锛�%d涓�", time.Now().Format("2006-01-02 15:04:05"), left) - b, e, aliasArr := service.PushByAlias("鑲茶嫳涓鍋滆溅", message, true) + b, e, aliasArr := service.PushByAlias("鍓╀綑杞︿綅鎻愰啋", message, true) //璁板綍鎺ㄩ�佹棩蹇� logE := models.Log{ Id: uuid.NewV4().String(), @@ -250,8 +250,8 @@ //灏嗗叿浣撶殑杞︿富淇℃伅鎺ㄩ�佺粰绠$悊鍛� if carOwnNames != nil && len(carOwnNames) >0 { //鑾峰彇杞︿富濮撳悕 - managerMsg := fmt.Sprintf("%s 鏈┒绂昏溅涓�: %s", time.Now().Format("2006-01-02 15:04:05"), strings.Join(carOwnNames, " ")) - mb,me, managerArr := service.Push2Manager("鑲茶嫳涓鍋滆溅", managerMsg) + managerMsg := strings.Join(carOwnNames, " ") + mb,me, managerArr := service.Push2Manager(fmt.Sprintf("%s 鏈┒绂昏溅杈�", time.Now().Format("2006-01-02 15:04:05")), managerMsg) mLogE := models.Log{ Id: uuid.NewV4().String(), CreateTime: time.Now().Format("2006-01-02 15:04:05"), @@ -265,7 +265,22 @@ } mLogE.Insert() fmt.Println("mb:", mb, "me:", me, "message:", managerMsg) + + c.Data["json"] = code.Code{ + Success: true, + Status: http.StatusOK, + Message: "鎺ㄩ�佸畬鎴�", + Data: managerMsg, + } + } else { + c.Data["json"] = code.Code{ + Success: true, + Status: http.StatusOK, + Message: "鏃犻渶鎺ㄩ�侊紝褰撳墠鍋滅暀杞﹁締淇℃伅涓虹┖", + } } + + c.ServeJSON() } // @router /spaceInfo [get] func (c *CarController) SpaceInfo() { diff --git a/service/msgPush.go b/service/msgPush.go index 7f19c39..2a0c879 100644 --- a/service/msgPush.go +++ b/service/msgPush.go @@ -184,6 +184,7 @@ androidPush := map[string]map[string]map[string]string { "ups": { "notification": { + "title": title, "body": msg, "big_text": msg, "click_type": "intent", @@ -195,6 +196,7 @@ "type":"notify", "aps":map[string]interface{}{ "alert":map[string]string{ + "title": title, "body": msg, }, "content-available":0, @@ -207,6 +209,7 @@ }, "push_message": map[string]map[string]string { "notification": { + "title": title, "body": msg, "click_type": "intent", "intent": intent, -- Gitblit v1.8.0