|
@@ -17,8 +17,8 @@ class HuaweiPushObject:
|
|
|
"""init sdk app"""
|
|
|
push_admin.initialize_app(self.app_id, self.app_secret)
|
|
|
|
|
|
- def send_push_notify_message(self, token_val, msg_title, msg_text, image_url=None, uid='', channel='', n_time='',
|
|
|
- event_type='', app_bundle_id='', appBundleId=''):
|
|
|
+ def send_push_notify_message(self, token_val, msg_title, msg_text, image_url=None, uid='', nickname='', channel='',
|
|
|
+ n_time='', event_type='', app_bundle_id='', appBundleId=''):
|
|
|
"""
|
|
|
发送推送消息
|
|
|
@param token_val: 手机推送token
|
|
@@ -43,10 +43,17 @@ class HuaweiPushObject:
|
|
|
body=msg_text,
|
|
|
image=image_url
|
|
|
)
|
|
|
+
|
|
|
+ # 自定义键值对
|
|
|
+ data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
|
+ 'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname
|
|
|
+ }
|
|
|
+ data = json.dumps(data)
|
|
|
# 推送通知内容配置
|
|
|
android_notification = self.android_notification(msg_title, msg_text)
|
|
|
# 安卓配置
|
|
|
android = messaging.AndroidConfig(
|
|
|
+ data=data,
|
|
|
collapse_key=-1,
|
|
|
urgency=messaging.AndroidConfig.NORMAL_PRIORITY,
|
|
|
ttl='10000s',
|
|
@@ -101,5 +108,5 @@ class HuaweiPushObject:
|
|
|
badge=messaging.AndroidBadgeNotification(
|
|
|
add_num=1, clazz='Classic'),
|
|
|
visibility=messaging.AndroidNotification.PUBLIC,
|
|
|
- foreground_show=True
|
|
|
+ foreground_show=False
|
|
|
)
|