|
@@ -133,7 +133,7 @@ class NotificationView(View):
|
|
|
# 改为1秒
|
|
|
# 如果不是正式
|
|
|
if SERVER_TYPE!="Ansjer.formal_settings":
|
|
|
- redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=10)
|
|
|
else:
|
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
|
|
@@ -145,7 +145,7 @@ class NotificationView(View):
|
|
|
# 设置推送时间为60秒一次
|
|
|
# 如果不是正式
|
|
|
if SERVER_TYPE != "Ansjer.formal_settings":
|
|
|
- redisObj.set_data(key=pkey, val=1, expire=1)
|
|
|
+ redisObj.set_data(key=pkey, val=1, expire=10)
|
|
|
else:
|
|
|
redisObj.set_data(key=pkey, val=1, expire=60)
|
|
|
auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
|
|
@@ -362,7 +362,7 @@ class NotificationView(View):
|
|
|
try:
|
|
|
serverKey = FCM_CONFIG[appBundleId]
|
|
|
except Exception as e:
|
|
|
- return
|
|
|
+ return 'serverKey abnormal'
|
|
|
push_service = FCMNotification(api_key=serverKey)
|
|
|
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}
|
|
@@ -379,7 +379,7 @@ class NotificationView(View):
|
|
|
|
|
|
def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title,
|
|
|
msg_text):
|
|
|
- # try:
|
|
|
+ try:
|
|
|
cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
|
|
|
@@ -392,19 +392,18 @@ class NotificationView(View):
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
res = cli.push(n=n, device_token=token_val, topic=appBundleId)
|
|
|
print(res.status_code)
|
|
|
- return res.status_code
|
|
|
+
|
|
|
if res.status_code == 200:
|
|
|
- print('apns push success')
|
|
|
- return
|
|
|
+ return res.status_code
|
|
|
else:
|
|
|
print('apns push fail')
|
|
|
print(res.reason)
|
|
|
- return
|
|
|
- # except (ValueError, ArithmeticError):
|
|
|
- # return 'The program has a numeric format exception, one of the arithmetic exceptions'
|
|
|
- # except Exception as e:
|
|
|
- # print(repr(e))
|
|
|
- # return repr(e)
|
|
|
+ return res.status_code
|
|
|
+ except (ValueError, ArithmeticError):
|
|
|
+ return 'The program has a numeric format exception, one of the arithmetic exceptions'
|
|
|
+ except Exception as e:
|
|
|
+ print(repr(e))
|
|
|
+ return repr(e)
|
|
|
|
|
|
|
|
|
# http://test.dvema.com/detect/add?uidToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJQMldOR0pSRDJFSEE1RVU5MTExQSJ9.xOCI5lerk8JOs5OcAzunrKCfCrtuPIZ3AnkMmnd-bPY&n_time=1526845794&channel=1&event_type=51&is_st=0
|