locky 4 недель назад
Родитель
Сommit
cb323cdc79
1 измененных файлов с 18 добавлено и 12 удалено
  1. 18 12
      Service/PushService.py

+ 18 - 12
Service/PushService.py

@@ -130,10 +130,13 @@ class PushObject:
             apns_url = "https://api.sandbox.push.apple.com" if CONFIG_INFO == CONFIG_TEST else "https://api.push.apple.com"
             apns_url = "https://api.sandbox.push.apple.com" if CONFIG_INFO == CONFIG_TEST else "https://api.push.apple.com"
             url = f"{apns_url}/3/device/{token_val}"
             url = f"{apns_url}/3/device/{token_val}"
 
 
+            jump_type = CommonService.get_jump_type(event_type)
+
             sound = 'call_phone.mp3' if event_type in DATA_PUSH_EVENT_TYPE_LIST else 'default'
             sound = 'call_phone.mp3' if event_type in DATA_PUSH_EVENT_TYPE_LIST else 'default'
 
 
             # 构造 body —— 把 image_url 等字段放顶层,便于 Notification Service Extension 直接读取
             # 构造 body —— 把 image_url 等字段放顶层,便于 Notification Service Extension 直接读取
             body = {
             body = {
+                "alert": msg_text,
                 "aps": {
                 "aps": {
                     "alert": {
                     "alert": {
                         "title": msg_title,
                         "title": msg_title,
@@ -143,16 +146,16 @@ class PushObject:
                     "category": "myCategory",
                     "category": "myCategory",
                     "mutable-content": 1
                     "mutable-content": 1
                 },
                 },
-                # ---- 把原来的 push_data 展平到顶层(尤其是 image_url) ----
-                "image_url": launch_image,
-                "uid": uid,
+                'jump_type': jump_type,
+                'image_url': launch_image,
                 "channel": channel,
                 "channel": channel,
-                "received_at": n_time,
                 "event_time": n_time,
                 "event_time": n_time,
                 "event_type": event_type,
                 "event_type": event_type,
-                "nickname": nickname,
-                "zpush": "1",
-                "jump_type": CommonService.get_jump_type(event_type)
+                "msg": "",
+                "received_at": n_time,
+                "sound": "",
+                "uid": uid,
+                "zpush": "1"
             }
             }
 
 
             headers = {
             headers = {
@@ -160,7 +163,7 @@ class PushObject:
                 "apns-push-type": "alert"
                 "apns-push-type": "alert"
             }
             }
 
 
-            with httpx.Client(http2=True, timeout=10, cert=str(pem_path)) as client:
+            with httpx.Client(http2=True,timeout=10, cert=str(pem_path),) as client:
                 res = client.post(url, headers=headers, json=body)
                 res = client.post(url, headers=headers, json=body)
 
 
             if res.status_code == 200:
             if res.status_code == 200:
@@ -241,15 +244,18 @@ class PushObject:
                         "category": "myCategory",
                         "category": "myCategory",
                         "mutable-content": 1
                         "mutable-content": 1
                     },
                     },
+                    # ---- 把原来的 push_data 展平到顶层(尤其是 image_url) ----
+                    "jump_type": CommonService.get_jump_type(event_type),
                     "image_url": launch_image,
                     "image_url": launch_image,
-                    "uid": uid,
                     "channel": channel,
                     "channel": channel,
-                    "received_at": n_time,
                     "event_time": n_time,
                     "event_time": n_time,
                     "event_type": event_type,
                     "event_type": event_type,
-                    "nickname": nickname,
+                    "msg":"",
+                    "received_at": n_time,
+                    "sound":"",
+                    "uid": uid,
                     "zpush": "1",
                     "zpush": "1",
-                    "jump_type": CommonService.get_jump_type(event_type)
+                    "nickname": nickname,
                 }
                 }
 
 
                 headers = {
                 headers = {