|
@@ -13,9 +13,10 @@ import time
|
|
|
|
|
|
import apns2
|
|
|
import jpush as jpush
|
|
|
+import requests
|
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
-from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, APP_BUNDLE_DICT
|
|
|
+from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE, APP_BUNDLE_DICT, XMPUSH_CONFIG
|
|
|
from AnsjerPush.config import SERVER_TYPE
|
|
|
from Model.models import UidPushModel, SysMsgModel, DeviceSharePermission, DeviceChannelUserSet, \
|
|
|
DeviceChannelUserPermission
|
|
@@ -182,6 +183,8 @@ class DevicePushService:
|
|
|
result['do_fcm_code'] = cls.do_fcm(**kwag_args)
|
|
|
elif push_type == 2: # android jpush
|
|
|
result['do_jpush_code'] = cls.do_jpush(**kwag_args)
|
|
|
+ elif push_type == 4: # android xmpush
|
|
|
+ result['do_xmpush_code'] = cls.do_jpush(**kwag_args)
|
|
|
return result
|
|
|
except Exception as e:
|
|
|
LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
@@ -357,6 +360,33 @@ class DevicePushService:
|
|
|
LOGGING.info('异常详情,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return repr(e)
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def do_xmpush(uid, channel, appBundleId, token_val, event_type, n_time,
|
|
|
+ msg_title, msg_text):
|
|
|
+ """
|
|
|
+ android 国内小米APP消息提醒推送
|
|
|
+ """
|
|
|
+ url = 'https://api.xmpush.xiaomi.com/v3/message/regid'
|
|
|
+ app_secret = XMPUSH_CONFIG[appBundleId]
|
|
|
+ payload = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
|
|
|
+ 'received_at': n_time, 'event_time': n_time, 'event_type': event_type,
|
|
|
+ 'uid': uid, 'channel': channel
|
|
|
+ }
|
|
|
+ data = {
|
|
|
+ 'title': msg_title,
|
|
|
+ 'description': msg_text,
|
|
|
+ 'payload': 'payload',
|
|
|
+ 'restricted_package_name': appBundleId,
|
|
|
+ 'registration_id': token_val,
|
|
|
+ }
|
|
|
+
|
|
|
+ headers = {
|
|
|
+ 'Authorization': 'key={}'.format(app_secret)
|
|
|
+ }
|
|
|
+ response = requests.post(url, data=data, headers=headers)
|
|
|
+ if response.status_code == 200:
|
|
|
+ return response.json()
|
|
|
+
|
|
|
@classmethod
|
|
|
def async_send_picture_push(cls, push_type, aws_s3_client, bucket, key, uid, appBundleId,
|
|
|
token_val, event_type, n_time, msg_title, msg_text, channel):
|