|
@@ -39,12 +39,10 @@ class GatewayPushService:
|
|
|
# ios apns 推送
|
|
|
@staticmethod
|
|
|
def ios_apns_push(nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text):
|
|
|
+ logger = logging.getLogger('info')
|
|
|
try:
|
|
|
- logger = logging.getLogger('info')
|
|
|
- logger.info('--->进来苹果推送')
|
|
|
pem_path = os.path.join(BASE_DIR, APNS_CONFIG[app_bundle_id]['pem_path'])
|
|
|
cli = apns2.APNSClient(mode=APNS_MODE, client_cert=pem_path)
|
|
|
- logger.info('--->证书路径{}'.format(pem_path))
|
|
|
alert = apns2.PayloadAlert(title=msg_title, body=msg_text)
|
|
|
push_data = {'alert': 'Motion', 'msg': '', 'sound': '', 'zpush': '1',
|
|
|
'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname
|
|
@@ -52,9 +50,9 @@ class GatewayPushService:
|
|
|
payload = apns2.Payload(alert=alert, custom=push_data, sound='default')
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
res = cli.push(n=n, device_token=token_val, topic=app_bundle_id)
|
|
|
- logger.info('--->苹果消息推送响应结果{}'.format(res))
|
|
|
assert res.status_code == 200
|
|
|
except Exception as e:
|
|
|
+ logger.info('--->IOS推送异常{}'.format(repr(e)))
|
|
|
return repr(e)
|
|
|
|
|
|
# android fcm 推送
|