|
@@ -1,16 +1,17 @@
|
|
|
import json
|
|
|
|
|
|
from AnsjerPush.config import LOGGER
|
|
|
+from Object.enums.EventTypeEnum import EventTypeEnumObj
|
|
|
from Service.HuaweiPushService import push_admin
|
|
|
from Service.HuaweiPushService.push_admin import messaging
|
|
|
-
|
|
|
+from AnsjerPush.config import HUAWEI_CONFIG
|
|
|
|
|
|
class HuaweiPushObject:
|
|
|
# 华为推送服务类
|
|
|
|
|
|
- def __init__(self):
|
|
|
- self.app_id = '101064781'
|
|
|
- self.app_secret = '29d5c5367208e35079f14779597b8f6bcc28ee39091546ed577862231fdd0fdd'
|
|
|
+ def __init__(self, appBundleId='com.ansjer.zccloud_ab'):
|
|
|
+ self.app_id = HUAWEI_CONFIG[appBundleId]['app_id']
|
|
|
+ self.app_secret = HUAWEI_CONFIG[appBundleId]['app_secret']
|
|
|
self.init_app()
|
|
|
|
|
|
def init_app(self):
|
|
@@ -41,7 +42,7 @@ class HuaweiPushObject:
|
|
|
|
|
|
send_succeed = self.send_notify_message(msg_title, msg_text, image_url, uid, nickname,
|
|
|
event_type, n_time, token_val, channel)
|
|
|
- if int(event_type) in [606, 607]:
|
|
|
+ if int(event_type) in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
|
|
|
self.send_data_message(uid, event_type, n_time, token_val, channel)
|
|
|
|
|
|
return send_succeed
|
|
@@ -71,9 +72,9 @@ class HuaweiPushObject:
|
|
|
|
|
|
# 自定义键值对
|
|
|
data = {
|
|
|
- 'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
|
|
|
- 'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel
|
|
|
- }
|
|
|
+ 'alert': msg_text, 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': uid, 'nickname': nickname,
|
|
|
+ 'event_type': event_type, 'received_at': n_time, 'event_time': n_time, 'channel': channel
|
|
|
+ }
|
|
|
data = json.dumps(data)
|
|
|
# 推送通知内容配置
|
|
|
intent = 'intent://com.vivo.pushvideo/detail?#Intent;scheme=vpushscheme;launchFlags=0x10000000;S.uid={};S.event_type={};S.event_time={};end'.format(
|