|
@@ -264,12 +264,13 @@ class PushObject:
|
|
|
|
|
|
@staticmethod
|
|
|
def android_vivopush(token_val, n_time, event_type, msg_title, msg_text, app_bundle_id='', uid='', channel='1',
|
|
|
- image='', nickname='', appBundleId=''):
|
|
|
+ image='', nickname='', appBundleId='', jg_token_val=''):
|
|
|
"""
|
|
|
vivo 推送(不支持图片)
|
|
|
@param app_bundle_id: app包名
|
|
|
@param appBundleId: app包名
|
|
|
@param token_val: 推送token
|
|
|
+ @param jg_token_val: 极光推送token
|
|
|
@param event_type: 事件类型
|
|
|
@param msg_title: 推送标题
|
|
|
@param msg_text: 推送内容
|
|
@@ -319,19 +320,22 @@ class PushObject:
|
|
|
.message_dict()
|
|
|
rec = sender_send.send(message)
|
|
|
logger.info('vivo推送结果:{}, 设备uid:{}'.format(rec, uid))
|
|
|
+ if rec['result'] == 0 and (event_type == 606 or event_type == '606'):
|
|
|
+ PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, push_data)
|
|
|
return rec
|
|
|
except Exception as e:
|
|
|
logger.info('vivo推送异常:{}'.format(e))
|
|
|
|
|
|
@staticmethod
|
|
|
def android_oppopush(channel_id, nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text,
|
|
|
- uid='', channel='1', image=''):
|
|
|
+ uid='', channel='1', image='', jg_token_val=''):
|
|
|
"""
|
|
|
android oppo 推送
|
|
|
@param channel_id: 通知通道id
|
|
|
@param nickname: 设备昵称
|
|
|
@param app_bundle_id: app包id
|
|
|
@param token_val: 推送token
|
|
|
+ @param jg_token_val: 推送token
|
|
|
@param n_time: 当前时间
|
|
|
@param event_type: 事件类型
|
|
|
@param msg_title: 推送标题
|
|
@@ -391,7 +395,8 @@ class PushObject:
|
|
|
|
|
|
response = requests.post(push_url, data=push_data, headers=headers)
|
|
|
logger.info("oppo推送返回值:{}".format(response.json()))
|
|
|
- assert response.status_code == 200
|
|
|
+ if response.status_code == 200 and (event_type == 606 or event_type == '606'):
|
|
|
+ PushObject.jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, jg_token_val, extra_data)
|
|
|
except Exception as e:
|
|
|
return repr(e)
|
|
|
|
|
@@ -456,3 +461,28 @@ class PushObject:
|
|
|
return response.status_code
|
|
|
except Exception as e:
|
|
|
return repr(e)
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def jpush_transparent_transmission(msg_title, msg_text, app_bundle_id, token_val, extra_data):
|
|
|
+ """
|
|
|
+ android 极光透传
|
|
|
+ @param msg_title: 推送标题
|
|
|
+ @param msg_text: 推送内容
|
|
|
+ @param token_val: 推送token
|
|
|
+ @param app_bundle_id: app包id
|
|
|
+ @param extra_data: 额外数据
|
|
|
+ @return: None
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ app_key = JPUSH_CONFIG[app_bundle_id]['Key']
|
|
|
+ master_secret = JPUSH_CONFIG[app_bundle_id]['Secret']
|
|
|
+ # 换成各自的app_key和master_secret
|
|
|
+ _jpush = jpush.JPush(app_key, master_secret)
|
|
|
+ push = _jpush.create_push()
|
|
|
+ push.audience = jpush.registration_id(token_val)
|
|
|
+ push.message = jpush.message(msg_content=msg_text, title=msg_title, extras=extra_data)
|
|
|
+ push.platform = jpush.all_
|
|
|
+ res = push.send()
|
|
|
+ assert res.status_code == 200
|
|
|
+ except Exception as e:
|
|
|
+ return repr(e)
|