Ver Fonte

修复ios推送无声音

lang há 3 anos atrás
pai
commit
23601b586a
2 ficheiros alterados com 6 adições e 23 exclusões
  1. 2 19
      Controller/DetectController.py
  2. 4 4
      Controller/DetectControllerV2.py

+ 2 - 19
Controller/DetectController.py

@@ -59,23 +59,6 @@ class NotificationView(View):
         n_time = request_dict.get('n_time', None)
         event_type = request_dict.get('event_type', None)
         is_st = request_dict.get('is_st', None)
-        debug = request_dict.get('is_debug', None)
-        if debug == 'test':
-            kwag_args = {
-                'uid': '6VCT4ENSU19T1RHX111A',
-                'channel': 1,
-                'event_type': 51,
-                'n_time': 1632303821,
-                'appBundleId': "com.ansjer.zccloud",
-                'token_val': 'e64cb19be68346e17a9a8cc1fdec88c6657addd9c0b6718db11d64bf8fa483e0',
-                'msg_title': 'ZOSI',
-                'msg_text': 'test'
-            }
-            do_apns_code = self.do_apns(**kwag_args)
-            return JsonResponse(status=200, data={
-                'code': 0,
-                'msg': do_apns_code})
-
         # print("aaa")
         # return JsonResponse(0,safe=False)
         if not all([channel, n_time]):
@@ -494,9 +477,9 @@ class NotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)

+ 4 - 4
Controller/DetectControllerV2.py

@@ -416,9 +416,9 @@ class NotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "default", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
@@ -925,9 +925,9 @@ class PWnotificationView(View):
                                    client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
 
             push_data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                         "received_at": n_time, "sound": "default", "uid": uid, "zpush": "1", "channel": channel}
+                         "received_at": n_time, "sound": "", "uid": uid, "zpush": "1", "channel": channel}
             alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
-            payload = apns2.Payload(alert=alert, custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data, sound="default")
 
             # return uid, channel, appBundleId, str(token_val), event_type, n_time, msg_title,msg_text
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)