|
@@ -18,6 +18,7 @@ from pyfcm import FCMNotification
|
|
|
|
|
|
from AnsjerPush.config import APP_BUNDLE_DICT, APNS_MODE, BASE_DIR, APNS_CONFIG, FCM_CONFIG, JPUSH_CONFIG, XMPUSH_CONFIG \
|
|
|
, VIVOPUSH_CONFIG, OPPOPUSH_CONFIG, MEIZUPUSH_CONFIG
|
|
|
+from Model.models import UidPushModel
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Service.CommonService import CommonService
|
|
|
from Service.VivoPushService.push_admin.APIMessage import PushMessage
|
|
@@ -250,16 +251,15 @@ class PushObject:
|
|
|
|
|
|
@staticmethod
|
|
|
def android_vivopush(token_val, n_time, event_type, msg_title, msg_text, app_bundle_id='', uid='', channel='1',
|
|
|
- image='', skip_type='1', nickname='', appBundleId=''):
|
|
|
+ image='', nickname='', appBundleId=''):
|
|
|
"""
|
|
|
vivo 推送(不支持图片)
|
|
|
@param app_bundle_id: app包名
|
|
|
@param appBundleId: app包名
|
|
|
@param token_val: 推送token
|
|
|
- @param event_type: 消息类型 (0:运营类消息,1:系统类消息。默认为 0)
|
|
|
+ @param event_type: 事件类型
|
|
|
@param msg_title: 推送标题
|
|
|
@param msg_text: 推送内容
|
|
|
- @param skip_type: 跳转类型(1:打开 APP 首页 2:打开链接 3:自定义 4:打开 app 内指定页面)
|
|
|
@param n_time: 当前时间
|
|
|
@param nickname: 设备昵称
|
|
|
@param uid: uid
|
|
@@ -270,42 +270,36 @@ class PushObject:
|
|
|
logger = logging.getLogger('info')
|
|
|
try:
|
|
|
app_bundle_id = app_bundle_id if app_bundle_id != '' else appBundleId
|
|
|
- authToken = 'authToken_' + app_bundle_id
|
|
|
- redisObj = RedisObject()
|
|
|
# 获取redis里面的authToken
|
|
|
- redis_authToken = redisObj.get_data(key=authToken)
|
|
|
if msg_title == '':
|
|
|
msg_title = APP_BUNDLE_DICT[app_bundle_id]
|
|
|
- if redis_authToken is not False:
|
|
|
- app_secret = VIVOPUSH_CONFIG[app_bundle_id]['Secret']
|
|
|
- sender_send = APISender(app_secret)
|
|
|
- sender_send.set_token(redis_authToken)
|
|
|
- else:
|
|
|
- skip_type = int(skip_type)
|
|
|
- app_id = VIVOPUSH_CONFIG[app_bundle_id]['ID']
|
|
|
- app_key = VIVOPUSH_CONFIG[app_bundle_id]['Key']
|
|
|
- app_secret = VIVOPUSH_CONFIG[app_bundle_id]['Secret']
|
|
|
- sender = APISender(app_secret)
|
|
|
- rec = sender.get_token(app_id, app_key)
|
|
|
- # 存放authToken,有效期3个小时
|
|
|
- redisObj = RedisObject()
|
|
|
- redisObj.set_data(key=authToken, val=rec['authToken'], expire=10800)
|
|
|
- sender_send = APISender(app_secret)
|
|
|
- sender_send.set_token(rec['authToken'])
|
|
|
+ app_id = VIVOPUSH_CONFIG[app_bundle_id]['ID']
|
|
|
+ app_key = VIVOPUSH_CONFIG[app_bundle_id]['Key']
|
|
|
+ app_secret = VIVOPUSH_CONFIG[app_bundle_id]['Secret']
|
|
|
+ sender = APISender(app_secret)
|
|
|
+ rec = sender.get_token(app_id, app_key)
|
|
|
+ # 鉴权接口调用获得authToken
|
|
|
+ sender_send = APISender(app_secret)
|
|
|
+ sender_send.set_token(rec['authToken'])
|
|
|
push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'image': image,
|
|
|
'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
|
|
|
'uid': uid, 'channel': channel
|
|
|
}
|
|
|
+ # 获取唯一标识符
|
|
|
+ uid_push_qs = UidPushModel.objects.filter(token_val=token_val).values('m_code')
|
|
|
+ m_code = uid_push_qs[0]['m_code'] if uid_push_qs[0]['m_code'] else ''
|
|
|
# 推送 push_mode: 推送模式 (0:正式推送;1:测试推送,默认为0)
|
|
|
+ # 推送 event_type: 消息类型 (0:运营类消息,1:系统类消息。默认为 0)
|
|
|
+ # 推送 skip_type: 跳转类型(1:打开 APP 首页 2:打开链接 3:自定义 4:打开 app 内指定页面)
|
|
|
message = PushMessage() \
|
|
|
.reg_id(token_val) \
|
|
|
.title(msg_title) \
|
|
|
.content(msg_text) \
|
|
|
.push_mode(1) \
|
|
|
.notify_type(3) \
|
|
|
- .skip_type(skip_type) \
|
|
|
- .request_id('123456') \
|
|
|
- .classification(1) \
|
|
|
+ .skip_type(1) \
|
|
|
+ .request_id(m_code) \
|
|
|
+ .classification(0) \
|
|
|
.client_custom_map(**push_data) \
|
|
|
.message_dict()
|
|
|
rec = sender_send.send(message)
|
|
@@ -406,7 +400,7 @@ class PushObject:
|
|
|
appId = MEIZUPUSH_CONFIG[app_bundle_id]['ID']
|
|
|
appSecret = MEIZUPUSH_CONFIG[app_bundle_id]['AppSecret']
|
|
|
url = 'https://server-api-push.meizu.com/garcia/api/server/push/varnished/pushByPushId'
|
|
|
- push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
|
+ extra_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
|
'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
|
|
|
'uid': uid, 'channel': channel
|
|
|
}
|
|
@@ -423,7 +417,7 @@ class PushObject:
|
|
|
'pushIds': token_val,
|
|
|
'messageJson': messageJson
|
|
|
}
|
|
|
- # 魅族MD5加密
|
|
|
+ # 魅族MD5加密,生成密钥
|
|
|
sign = CommonService.getMD5Sign(data=data_meizu, key=appSecret)
|
|
|
data = {
|
|
|
'appId': appId,
|