|
@@ -35,35 +35,49 @@ class HuaweiPushObject:
|
|
|
@return:
|
|
|
"""
|
|
|
logger = logging.getLogger('info')
|
|
|
- logger.info('华为推送参数:{}, {}, {}, {}'.format(token_val, msg_title, msg_text, image_url))
|
|
|
+ logger.info(
|
|
|
+ '华为推送参数: token_val:{}, msg_title:{}, msg_text:{}, image_url:{}, uid:{}, event_type:{}, n_time:{}'.format(
|
|
|
+ token_val, msg_title, msg_text, image_url, uid, event_type, n_time))
|
|
|
|
|
|
- msg_title = '设备昵称: {}'.format(msg_title)
|
|
|
- notification = messaging.Notification(
|
|
|
- title=msg_title,
|
|
|
- body=msg_text,
|
|
|
- image=image_url
|
|
|
- )
|
|
|
+ if event_type == '606':
|
|
|
+ message_data = {'uid': uid, 'event_type': event_type, 'event_time': n_time}
|
|
|
+ notification = None
|
|
|
+ android = messaging.AndroidConfig(
|
|
|
+ collapse_key=-1,
|
|
|
+ urgency=messaging.AndroidConfig.HIGH_PRIORITY,
|
|
|
+ ttl='10000s',
|
|
|
+ bi_tag='the_sample_bi_tag_for_receipt_service'
|
|
|
+ )
|
|
|
+ else:
|
|
|
+ message_data = None
|
|
|
+ msg_title = '设备昵称: {}'.format(msg_title)
|
|
|
+ notification = messaging.Notification(
|
|
|
+ title=msg_title,
|
|
|
+ body=msg_text,
|
|
|
+ image=image_url
|
|
|
+ )
|
|
|
|
|
|
- # 自定义键值对
|
|
|
- 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,
|
|
|
- 'action': 'com.ansjer.zccloud_a.AJ_MainView.AJ_Home.AJMainActivity'
|
|
|
- }
|
|
|
- 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',
|
|
|
- bi_tag='the_sample_bi_tag_for_receipt_service',
|
|
|
- notification=android_notification,
|
|
|
- category='DEVICE_REMINDER'
|
|
|
- )
|
|
|
+ # 自定义键值对
|
|
|
+ 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,
|
|
|
+ 'action': 'com.ansjer.zccloud_a.AJ_MainView.AJ_Home.AJMainActivity'
|
|
|
+ }
|
|
|
+ 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',
|
|
|
+ bi_tag='the_sample_bi_tag_for_receipt_service',
|
|
|
+ notification=android_notification,
|
|
|
+ category='DEVICE_REMINDER'
|
|
|
+ )
|
|
|
|
|
|
message = messaging.Message(
|
|
|
+ data=message_data,
|
|
|
notification=notification,
|
|
|
android=android,
|
|
|
token=[token_val]
|