|
@@ -42,21 +42,17 @@ class Test(View):
|
|
|
# 'appbundleId': {'pem_path': 'xxxx', 'topic': 'topic', 'password': 'password'}
|
|
|
# }
|
|
|
try:
|
|
|
- # daytime = time.strftime("%Y%m%d%H%M", time.localtime(1547256103))
|
|
|
- # print(daytime)
|
|
|
- # pem_path = os.path.join(BASE_DIR, 'Ansjer/file/apns-dev.pem')
|
|
|
- # cli = apns2.APNSClient(mode="dev", client_cert=pem_path, password='111111')
|
|
|
- cli = apns2.APNSClient(mode="prod", client_cert=pem_path, password='1234')
|
|
|
- # cli = apns2.APNSClient(mode="dev", client_cert=pem_path, password='1234')
|
|
|
+ import apns2
|
|
|
now_time = int(time.time())
|
|
|
+
|
|
|
+ cli = apns2.APNSClient(mode="prod", client_cert=pem_path)
|
|
|
push_data = {"alert": "Motion ", "event_time": now_time, "event_type": '51', "msg": "",
|
|
|
"received_at": now_time, "sound": "sound.aif", "uid": "XFDJUHUIOKJHYTGSFFDR"}
|
|
|
- alert = apns2.PayloadAlert(body=push_data, title="title!")
|
|
|
+ alert = apns2.PayloadAlert(body=json.dumps(push_data), title="title!")
|
|
|
payload = apns2.Payload(alert=alert)
|
|
|
+
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
- res = cli.push(n=n, device_token=token_val, topic=pem_path)
|
|
|
- # assert res.status_code == 200, res.reason
|
|
|
- # assert res.apns_id
|
|
|
+ res = cli.push(n=n, device_token=token_val,topic='com.ansjer.zccloud')
|
|
|
if res.status_code == 200:
|
|
|
return response.json(0)
|
|
|
else:
|