|
@@ -34,7 +34,7 @@ class Test(View):
|
|
|
|
|
|
|
|
|
request_dict = request.GET
|
|
|
- # return self.do_apns(request_dict)
|
|
|
+ return self.do_apns(request_dict)
|
|
|
# return self.do_get_putOss_url(request.GET)
|
|
|
# from django.http import JsonResponse
|
|
|
# return JsonResponse(status=200,data={
|
|
@@ -73,21 +73,30 @@ class Test(View):
|
|
|
|
|
|
def do_apns(self,request_dict):
|
|
|
token_val = request_dict.get('token_val',None)
|
|
|
- pem_path = os.path.join(BASE_DIR,'Ansjer/file/apns_pem/apns-dev.pem')
|
|
|
+ pem_path = 'D:/13.56.215.252/git/AnsjerFormal/Ansjer/file/apns_pem/apns-dev-test.pem'
|
|
|
print(pem_path)
|
|
|
response = ResponseObject()
|
|
|
try:
|
|
|
import apns2
|
|
|
now_time = int(time.time())
|
|
|
|
|
|
- cli = apns2.APNSClient(mode="prod", client_cert=pem_path)
|
|
|
+ # cli = apns2.APNSClient(mode="dev", client_cert="/your/path.pem")
|
|
|
+ # alert = apns2.PayloadAlert(body="body!", title="title!")
|
|
|
+ # payload = apns2.Payload(alert=alert)
|
|
|
+ # n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
+ # response = cli.push(n=n, device_token="your_token")
|
|
|
+ # assert response.status_code == 200, response.reason
|
|
|
+ # assert response.apns_id
|
|
|
+
|
|
|
+ # cli = apns2.APNSClient(mode="prod", client_cert=pem_path)
|
|
|
+ cli = apns2.APNSClient(mode="dev", client_cert=pem_path,password='111111')
|
|
|
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=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='com.ansjer.zccloud')
|
|
|
+ res = cli.push(n=n, device_token=token_val,topic='com.ansjer.loocamccloud')
|
|
|
if res.status_code == 200:
|
|
|
return response.json(0)
|
|
|
else:
|