浏览代码

极光推送增加uid和通道id

peng 1 年之前
父节点
当前提交
1c70b8c74a
共有 3 个文件被更改,包括 8 次插入4 次删除
  1. 1 0
      Controller/PowerWarningController.py
  2. 2 1
      Service/DevicePushService.py
  3. 5 3
      Service/PushService.py

+ 1 - 0
Controller/PowerWarningController.py

@@ -91,6 +91,7 @@ class PowerWarningView(View):
                     elif push_type == 1:  # android gcm
                         PushObject.android_fcm_push(**kwargs)
                     elif push_type == 2:  # android jpush
+                        kwargs.pop('uid')
                         PushObject.android_jpush(**kwargs)
                     elif push_type == 3:
                         huawei_push_object = HuaweiPushObject()

+ 2 - 1
Service/DevicePushService.py

@@ -313,7 +313,8 @@ class DevicePushService:
                                                                            param['token_val'], param['n_time'],
                                                                            param['event_type'],
                                                                            param['kwag_args']['msg_title'],
-                                                                           param['kwag_args']['msg_text'])
+                                                                           param['kwag_args']['msg_text'],
+                                                                           param['channel'])
                     elif push_type == 3:
                         huawei_push_object = HuaweiPushObject()
                         huawei_push_object.send_push_notify_message(**kwargs)

+ 5 - 3
Service/PushService.py

@@ -174,7 +174,7 @@ class PushObject:
             LOGGER.info('fcm推送异常:{}'.format(repr(e)))
 
     @staticmethod
-    def android_jpush(nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text):
+    def android_jpush(nickname, app_bundle_id, token_val, n_time, event_type, msg_title, msg_text, channel=1):
         """
         android 极光 推送
         @param nickname: 设备昵称
@@ -184,6 +184,7 @@ class PushObject:
         @param event_type: 事件类型
         @param msg_title: 推送标题
         @param msg_text: 推送内容
+        @param channel: 设备通道
         @return: None
         """
         try:
@@ -193,8 +194,9 @@ class PushObject:
             _jpush = jpush.JPush(app_key, master_secret)
             push = _jpush.create_push()
             push.audience = jpush.registration_id(token_val)
-            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1',
-                         'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname
+            push_data = {'alert': 'Motion', 'msg': '', 'sound': 'sound.aif', 'zpush': '1', 'uid': nickname,
+                         'received_at': n_time, 'event_time': n_time, 'event_type': event_type, 'nickname': nickname,
+                         'channel': channel
                          }
             android = jpush.android(title=msg_title, big_text=msg_text, alert=msg_text, extras=push_data,
                                     priority=1, style=1, alert_type=7