|
@@ -5,6 +5,7 @@
|
|
|
@File :GatewayService.py
|
|
|
@IDE :PyCharm
|
|
|
"""
|
|
|
+import logging
|
|
|
import os
|
|
|
|
|
|
import apns2
|
|
@@ -39,6 +40,7 @@ class GatewayPushService:
|
|
|
@staticmethod
|
|
|
def ios_apns_push(nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text):
|
|
|
try:
|
|
|
+ logger = logging.getLogger('info')
|
|
|
cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
client_cert=os.path.join(BASE_DIR, APNS_CONFIG[app_bundle_id]['pem_path']))
|
|
|
alert = apns2.PayloadAlert(title=msg_title, body=msg_text)
|
|
@@ -48,6 +50,7 @@ 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:
|
|
|
return repr(e)
|