Browse Source

微瞳华为推送

locky 7 tháng trước cách đây
mục cha
commit
77529fb222

+ 12 - 1
AnsjerPush/cn_config/cn_formal_config.py

@@ -230,4 +230,15 @@ HONORPUSH_CONFIG = {
         'client_secret': 'BZJLdZ8NlvJohIr8nSD1i6KUkUiUmcVh',
         'app_id': 104481203
     }
-}
+}
+
+HUAWEI_CONFIG = {
+    'com.ansjer.zccloud_ab': {
+        'app_id': '101064781',
+        'app_secret': '29d5c5367208e35079f14779597b8f6bcc28ee39091546ed577862231fdd0fdd'
+    },
+    'com.cloudlife.commissionf_a': {
+        'app_id': '108703647',
+        'app_secret': '6bc5b0b0ab4588fcd667b3e6c1ab4fd5d857de21ad69ee9d46e077b9f5f24e8f'
+    }
+}

+ 2 - 2
Service/DevicePushService.py

@@ -450,7 +450,7 @@ class DevicePushService:
                         push_result = PushObject.android_jpush(**kwargs)
 
                 elif push_type == 3:
-                    huawei_push_object = HuaweiPushObject()
+                    huawei_push_object = HuaweiPushObject(appBundleId=kwargs["appBundleId"])
                     huawei_push_object.send_push_notify_message(**push_kwargs)
                 elif push_type == 4:  # android xmpush
                     if kwargs['event_type'] in EventTypeEnumObj.DATA_PUSH_EVENT_TYPE_LIST.value:
@@ -791,7 +791,7 @@ class DevicePushService:
                 push_result = PushObject.android_fcm_push_v1(
                     uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text, uid, channel, image_url)
             elif push_type == 3:
-                huawei_push_object = HuaweiPushObject()
+                huawei_push_object = HuaweiPushObject(appBundleId=appBundleId)
                 push_result = huawei_push_object.send_push_notify_message(
                     token_val=token_val, msg_title=msg_title, msg_text=msg_text, uid=uid, event_type=event_type,
                     n_time=n_time, image_url=image_url, channel=channel)

+ 9 - 8
Service/HuaweiPushService/HuaweiPushService.py

@@ -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(