|
@@ -22,7 +22,6 @@ from Ansjer.config import BASE_DIR
|
|
|
import json
|
|
|
from alipay import AliPay
|
|
|
import time
|
|
|
-import apns2
|
|
|
from django.http import JsonResponse
|
|
|
|
|
|
|
|
@@ -37,8 +36,6 @@ class Test(View):
|
|
|
return self.jgPush(request)
|
|
|
elif test_push_type == 'fcm':
|
|
|
return self.do_fcm_push(request)
|
|
|
- elif test_push_type == 'apns':
|
|
|
- return self.do_apns(request.GET)
|
|
|
elif test_push_type == 's3sts':
|
|
|
return self.do_get_s3_sts()
|
|
|
return self.do_gcm_push(request)
|
|
@@ -173,33 +170,6 @@ class Test(View):
|
|
|
response = ResponseObject()
|
|
|
return response.json(0, result)
|
|
|
|
|
|
- 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-dev2.pem')
|
|
|
- # pem_path = os.path.join(BASE_DIR, 'Ansjer/file/apns_pem/apns-loocamccloud.pem')
|
|
|
- print(pem_path)
|
|
|
- response = ResponseObject()
|
|
|
- try:
|
|
|
- n_time = int(time.time())
|
|
|
-
|
|
|
- cli = apns2.APNSClient(mode="dev", client_cert=pem_path,
|
|
|
- password='111111')
|
|
|
- push_data = {"alert": "Motion ", "event_time": n_time, "event_type": 51, "msg": "",
|
|
|
- "received_at": n_time, "sound": "sound.aif", "uid": 'XFDJUHUIOKJHYTGSFFDR', "zpush": "1", "channel": 1}
|
|
|
- alert = apns2.PayloadAlert(body='通道:1 uid:XFDJUHUIOKJHYTGSFFDR', title='ansjer')
|
|
|
- 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='com.ansjer.loocamccloud')
|
|
|
- # assert res.status_code == 200, res.reason
|
|
|
- # assert res.apns_id
|
|
|
- if res.status_code == 200:
|
|
|
- return response.json(0)
|
|
|
- else:
|
|
|
- return response.json(404, res.reason)
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- return response.json(10, repr(e))
|
|
|
-
|
|
|
def do_get_putOss_url(self, request_dict):
|
|
|
import oss2
|
|
|
obj_name = request_dict.get('obj_name', '')
|