浏览代码

修改推送增加震动,增加呼吸灯

chenjunkai 6 年之前
父节点
当前提交
8ce6c43335
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 8 3
      Controller/DetectController.py
  2. 1 0
      Controller/Test.py

+ 8 - 3
Controller/DetectController.py

@@ -372,7 +372,7 @@ class NotificationView(View):
             else:
                 message_title = "zosi({uid})".format(uid=uid)
             send_text = 'channel:{channel} date:{date}'.format(channel=channel, date=n_date)
-        android = jpush.android(alert=send_text, priority=1, style=1, alert_type=1,
+        android = jpush.android(alert=send_text, priority=1, style=1, alert_type=7,
                                 big_text=send_text, title=message_title,
                                 extras=push_data)
 
@@ -455,7 +455,12 @@ class NotificationView(View):
         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}
         result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
-                                                   message_body=send_text, data_message=data)
+                                                   message_body=send_text, data_message=data,
+                                                   extra_kwargs={
+                                                       'default_vibrate_timings': True,
+                                                       'default_sound': True,
+                                                       'default_light_settings': True
+                                                   })
         response = ResponseObject()
         return response.json(0, result)
 
@@ -491,7 +496,7 @@ class NotificationView(View):
                          "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
             # body = json.dumps(push_data)
             alert = apns2.PayloadAlert(body=send_text, title=message_title)
-            payload = apns2.Payload(alert=alert,custom=push_data)
+            payload = apns2.Payload(alert=alert, custom=push_data)
             n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
             res = cli.push(n=n, device_token=token_val, topic=appBundleId)
             # assert res.status_code == 200, res.reason

+ 1 - 0
Controller/Test.py

@@ -209,6 +209,7 @@ class Test(View):
         # if you set the logging level to "DEBUG",it will show the debug logging.
         _jpush.set_logging("DEBUG")
         # push.audience = jpush.all_
+
         n_time = int(time.time())
         event_type = 51
         push.audience = jpush.registration_id(devToken)