|
@@ -229,7 +229,7 @@ class NotificationView(View):
|
|
|
appBundleId = uaql['appBundleId']
|
|
|
uid = uaql['uid']
|
|
|
apns_config = {
|
|
|
- 'appbundleId': {'pem_path': 'xxxx', 'topic': 'topic'}
|
|
|
+ 'appbundleId': {'pem_path': 'xxxx', 'topic': 'topic','password':'password'}
|
|
|
}
|
|
|
try:
|
|
|
# daytime = time.strftime("%Y%m%d%H%M", time.localtime(1547256103))
|
|
@@ -243,7 +243,7 @@ class NotificationView(View):
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
res = cli.push(n=n, device_token=token_val, topic=apns_config[appBundleId]['pem_path'])
|
|
|
# assert res.status_code == 200, res.reason
|
|
|
- # assert res.apns_id
|
|
|
+ # assert res.apns_id
|
|
|
if res.status_code == 200:
|
|
|
self.do_save_equipment_info(uaql, n_time)
|
|
|
return response.json(0)
|
|
@@ -253,13 +253,17 @@ class NotificationView(View):
|
|
|
return response.json(10, repr(e))
|
|
|
|
|
|
def do_save_equipment_info(self, uaql, n_time):
|
|
|
- Equipment_Info.objects.create(
|
|
|
- userID_id=uaql['userID_id'],
|
|
|
- eventTime=n_time,
|
|
|
- eventType=1,
|
|
|
- devUid=uaql['uid'],
|
|
|
- devNickName=uaql['devNickName'],
|
|
|
- Channel='0',
|
|
|
- alarm='xxx',
|
|
|
- receiveTime=n_time)
|
|
|
- return True
|
|
|
+ try:
|
|
|
+ Equipment_Info.objects.create(
|
|
|
+ userID_id=uaql['userID_id'],
|
|
|
+ eventTime=n_time,
|
|
|
+ eventType=1,
|
|
|
+ devUid=uaql['uid'],
|
|
|
+ devNickName=uaql['devNickName'],
|
|
|
+ Channel='0',
|
|
|
+ alarm='0',
|
|
|
+ receiveTime=n_time)
|
|
|
+ except Exception as e:
|
|
|
+ return False
|
|
|
+ else:
|
|
|
+ return True
|