Преглед на файлове

极光推送增加channel数据

peng преди 2 години
родител
ревизия
e7145fd699
променени са 4 файла, в които са добавени 7 реда и са изтрити 4 реда
  1. 0 1
      Controller/AiController.py
  2. 1 0
      Controller/PowerWarningController.py
  3. 2 1
      Service/DevicePushService.py
  4. 4 2
      Service/PushService.py

+ 0 - 1
Controller/AiController.py

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

+ 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

@@ -314,7 +314,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)

+ 4 - 2
Service/PushService.py

@@ -185,7 +185,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: 设备昵称
@@ -195,6 +195,7 @@ class PushObject:
         @param event_type: 事件类型
         @param msg_title: 推送标题
         @param msg_text: 推送内容
+        @param channel: 设备通道
         @return: None
         """
         try:
@@ -205,7 +206,8 @@ class PushObject:
             push = _jpush.create_push()
             push.audience = jpush.registration_id(token_val)
             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
+                         '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