From bcf436fb329fb2c8b6e4a373efd11a679e0b98a0 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 31 八月 2020 09:49:33 +0800
Subject: [PATCH] fix push log

---
 service/msgPush.go |   44 +++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/service/msgPush.go b/service/msgPush.go
index 05ebef6..3801326 100644
--- a/service/msgPush.go
+++ b/service/msgPush.go
@@ -181,6 +181,27 @@
 	}
 	url := baseUrl+"/push/list/message"
 	intent := "intent:#Intent;action=android.intent.action.oppopush;launchFlags=0x14000000;component=uni.UNIEDF0B5C/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title="+title+";S.content="+msg+";S.payload=test;end"
+	androidPush := map[string]map[string]map[string]string {
+		"ups": {
+			"notification": {
+				"title": title,
+				"body": msg,
+				"click_type": "intent",
+				"intent": intent,
+			},
+		},
+	}
+	iosPush := map[string]interface{}{
+		"type":"notify",
+		"payload":"鑲茶嫳涓鍋滆溅",
+		"aps":map[string]interface{}{
+			"alert":map[string]string{
+				"title": title,
+				"body": msg,
+			},
+			"content-available":0,
+		},
+	}
 	reqBody := map[string]interface{} {
 		"request_id": time.Now().Format("20060102150405") + util.GenValidateCode(6),
 		"settings":map[string]int {
@@ -194,17 +215,9 @@
 				"intent": intent,
 			},
 		},
-		"push_channel": map[string]map[string]map[string]map[string]string {
-			"android": {
-				"ups": {
-					"notification": {
-						"title": title,
-						"body": msg,
-						"click_type": "intent",
-						"intent": intent,
-					},
-				},
-			},
+		"push_channel": map[string]interface{} {
+			"android": androidPush,
+			"ios":iosPush,
 		},
 	}
 	header := map[string]string {
@@ -297,7 +310,7 @@
 	}
 	lenAS := len(aliasArr)
 	if  lenAS == 0 {
-		return false, errors.New("aliasArr is empty"),aliasArr
+		return false, errors.New("娌℃湁鎺ㄩ�佺洰鏍囷紝aliasArr is empty"),aliasArr
 	}
 	if isTest {
 		//鍙粰鍐呴儴鎵嬫満鍙锋帹
@@ -423,7 +436,7 @@
 		}
 	}
 	if len(pushUserM) == 0 {
-		return true,nil, aliasArr
+		return false, errors.New("len(pushUserM) == 0"), aliasArr
 	}
 	carPersonM := make(map[string]string)
 	csv := NewCarService()
@@ -449,7 +462,7 @@
 
 	if len(aliasArr) == 0 {
 		fmt.Println("娌℃湁鎺ㄩ�佺洰鏍�,aliasArr is empty")
-		return true, nil, aliasArr
+		return false, errors.New("娌℃湁鎺ㄩ�佺洰鏍�,aliasArr is empty"), aliasArr
 	}
 
 	cResult, taskId, ce := createPushMsg(title, msg)
@@ -462,6 +475,7 @@
 	return b,e, aliasArr
 }
 
+/*
 func PushAll(title string, msg string) (bool,error) {
 	appId := beego.AppConfig.String("pushAppId")
 	baseUrl := beego.AppConfig.String("pushBaseUrl") + appId
@@ -546,7 +560,7 @@
 	}
 
 	return false, errors.New("鎺ㄩ�佸け璐�")
-}
+}*/
 
 func RefreshToken() (*TokenResult,error) {
 	appId := beego.AppConfig.String("pushAppId")

--
Gitblit v1.8.0