Browse Source

gcm推送测试

lang 3 năm trước cách đây
mục cha
commit
3131c4f511
1 tập tin đã thay đổi với 17 bổ sung12 xóa
  1. 17 12
      Controller/AiController.py

+ 17 - 12
Controller/AiController.py

@@ -630,20 +630,25 @@ class AiView(View):
                      'msg_id' : msg_id,
                 }
                 # 推送消息
-                if push_type == 0:  # ios apns
+                # if push_type == 0:  # ios apns
+                #     logger.info('into-------apns')
+                #     apns_start_time = int(time.time())
+                #     res = self.do_apns(**kwargs)
+                #     apns_end_time = int(time.time())
+                #     logger.info(res)
+                # # elif push_type == 1:  # android gcm
+                # #     self.do_fcm(**kwargs)
+                # elif push_type == 2:  # android jpush
+                #     logger.info('into-------jpush')
+                #     jpush_start_time = int(time.time())
+                #     res = self.do_jpush(**kwargs)
+                #     jpush_end_time = int(time.time())
+                #     logger.info(res)
+                if push_type == 1:  # android gcm
                     logger.info('into-------apns')
                     apns_start_time = int(time.time())
-                    res = self.do_apns(**kwargs)
+                    res = self.do_fcm(**kwargs)
                     apns_end_time = int(time.time())
-                    logger.info(res)
-                # elif push_type == 1:  # android gcm
-                #     self.do_fcm(**kwargs)
-                elif push_type == 2:  # android jpush
-                    logger.info('into-------jpush')
-                    jpush_start_time = int(time.time())
-                    res = self.do_jpush(**kwargs)
-                    jpush_end_time = int(time.time())
-                    logger.info(res)
 
                 # 以下是存库
                 userID_id = up["userID_id"]
@@ -803,7 +808,7 @@ class AiView(View):
             return 'serverKey abnormal'
         push_service = FCMNotification(api_key=serverKey)
         data = {"alert": "Motion ", "event_time": n_time, "event_type": event_type, "msg": "",
-                "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel}
+                "received_at": n_time, "sound": "sound.aif", "uid": uid, "zpush": "1", "channel": channel, "msg_id": msg_id}
         result = push_service.notify_single_device(registration_id=token_val, message_title=msg_title,
                                                    message_body=msg_text, data_message=data,
                                                    extra_kwargs={