|
@@ -645,7 +645,7 @@ class AiView(View):
|
|
|
# jpush_end_time = int(time.time())
|
|
|
# logger.info(res)
|
|
|
if push_type == 1: # android gcm
|
|
|
- logger.info('into-------apns')
|
|
|
+ logger.info('into-------gcm')
|
|
|
apns_start_time = int(time.time())
|
|
|
res = self.do_fcm(**kwargs)
|
|
|
apns_end_time = int(time.time())
|
|
@@ -804,21 +804,23 @@ class AiView(View):
|
|
|
def do_fcm(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text, msg_id=0):
|
|
|
try:
|
|
|
serverKey = FCM_CONFIG[appBundleId]
|
|
|
+ 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,
|
|
|
+ "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={
|
|
|
+ 'default_vibrate_timings': True,
|
|
|
+ 'default_sound': True,
|
|
|
+ 'default_light_settings': True
|
|
|
+ })
|
|
|
+ print('fcm push ing')
|
|
|
+ print(result)
|
|
|
+ return result
|
|
|
except Exception as e:
|
|
|
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, "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={
|
|
|
- 'default_vibrate_timings': True,
|
|
|
- 'default_sound': True,
|
|
|
- 'default_light_settings': True
|
|
|
- })
|
|
|
- print('fcm push ing')
|
|
|
- print(result)
|
|
|
- return result
|
|
|
+
|
|
|
|
|
|
def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title, msg_text, msg_id=0):
|
|
|
logger = logging.getLogger('info')
|