瀏覽代碼

Merge remote-tracking branch 'remotes/origin/locky' into test

Ansjer 2 年之前
父節點
當前提交
c3e0ac92e3
共有 2 個文件被更改,包括 12 次插入12 次删除
  1. 2 2
      Service/DevicePushService.py
  2. 10 10
      Service/HuaweiPushService/HuaweiPushService.py

+ 2 - 2
Service/DevicePushService.py

@@ -465,8 +465,8 @@ class DevicePushService:
                                             msg_text, uid, channel, image_url)
             elif push_type == 3:
                 huawei_push_object = HuaweiPushObject()
-                huawei_push_object.send_push_android_notify_message(title=msg_title, body=msg_text, image=image_url,
-                                                                    token=token_val)
+                huawei_push_object.send_push_notify_message(nickname=uid, msg_title=msg_title, msg_text=msg_text,
+                                                            image_url=image_url, token_val=token_val)
             elif push_type == 4:
                 PushObject.android_xmpush(uid, appBundleId, token_val, n_time, event_type, msg_title,
                                           msg_text, uid, channel, image_url)

+ 10 - 10
Service/HuaweiPushService/HuaweiPushService.py

@@ -16,7 +16,7 @@ class HuaweiPushObject:
         """init sdk app"""
         push_admin.initialize_app(self.app_id, self.app_secret)
 
-    def send_push_android_notify_message(self, title, body, image, token):
+    def send_push_notify_message(self, nickname, msg_title, msg_text, image_url, token_val):
         """
         发送推送消息
 
@@ -25,12 +25,12 @@ class HuaweiPushObject:
         """
 
         notification = messaging.Notification(
-            title=title,
-            body=body,
-            image=image
+            title=msg_title,
+            body=msg_text,
+            image=image_url
         )
         # 推送通知内容配置
-        android_notification = self.android_notification(title, body)
+        android_notification = self.android_notification(nickname, msg_title, msg_text)
         # 安卓配置
         android = messaging.AndroidConfig(
             collapse_key=-1,
@@ -44,7 +44,7 @@ class HuaweiPushObject:
         message = messaging.Message(
             notification=notification,
             android=android,
-            token=[token]
+            token=[token_val]
         )
 
         try:
@@ -61,7 +61,7 @@ class HuaweiPushObject:
             print(repr(e))
 
     @staticmethod
-    def android_notification(title, body):
+    def android_notification(nickname, msg_title, msg_text):
         return messaging.AndroidNotification(
             icon='/raw/ic_launcher2',
             color='#AACCDD',
@@ -76,11 +76,11 @@ class HuaweiPushObject:
             title_loc_key='M.String.title',
             title_loc_args=['Girl', 'Cat'],
             channel_id='1',
-            notify_summary='some summary',
+            notify_summary=nickname,
             multi_lang_key={'title_key': {'en': 'value1'}, 'body_key': {'en': 'value2'}},
             style=0,
-            big_title=title,
-            big_body=body,
+            big_title=msg_title,
+            big_body=msg_text,
             auto_clear=86400000,
             notify_id=4861,
             group='Group1',