jiangjc 1 month ago
parent
commit
3388a3a247

+ 14 - 4
OASystem/OASystem.Api/OAMethodLib/APNs/APNsService.cs

@@ -111,8 +111,9 @@ namespace OASystem.API.OAMethodLib.APNs
         /// <param name="subtitle">子标题</param>
         /// <param name="body">通知内容</param>
         /// <returns></returns>
-        public async Task<string> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
+        public async Task<Result> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body)
         {
+            Result result = new Result() { Code = -1, Msg = "未知错误" };
             var responseData = FailedAPNsReponseData();
             var token = this.GetnerateAPNsJWTToken();
             var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, APNsService.baseUrl + deviceToken)
@@ -152,18 +153,27 @@ namespace OASystem.API.OAMethodLib.APNs
                 if (httpResponseMessage.IsSuccessStatusCode)
                 {
                     responseData.Code = 200;
-                    return System.Text.Json.JsonSerializer.Serialize(responseData);
+                    result.Code = 0;
+                    result.Msg = "";
+                    result.Data = responseData;
+                    return result;
                 }
                 else
                 {
                     responseData.Data = httpResponseMessage.StatusCode;
-                    return System.Text.Json.JsonSerializer.Serialize(responseData);
+                    result.Code = -2;
+                    result.Msg = "";
+                    result.Data = responseData;
+                    return result;
                 }
             }
             catch (Exception e)
             {
                 responseData.Data = e.Message;
-                return System.Text.Json.JsonSerializer.Serialize(responseData);
+                result.Code = -3;
+                result.Msg = "";
+                result.Data = responseData;
+                return result;
             }
         }
 

+ 1 - 1
OASystem/OASystem.Api/OAMethodLib/APNs/IAPNsService.cs

@@ -18,6 +18,6 @@
         /// <param name="subtitle">子标题</param>
         /// <param name="body">通知内容</param>
         /// <returns></returns>
-        Task<string> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
+        Task<Result> PushNotification(string apnsTopic, string deviceToken, NotificationType type, string title, string subtitle, string body);
     }
 }