|
@@ -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',
|