|
@@ -156,7 +156,9 @@ class NotificationView(View):
|
|
|
eq_list = []
|
|
|
sys_msg_list = []
|
|
|
userID_ids = []
|
|
|
- do_apnsss=''
|
|
|
+ do_apns_code = ''
|
|
|
+ do_fcm_code = ''
|
|
|
+ do_jpush_code = ''
|
|
|
for up in redis_list:
|
|
|
push_type = up['push_type']
|
|
|
appBundleId = up['appBundleId']
|
|
@@ -176,11 +178,11 @@ class NotificationView(View):
|
|
|
if detect_med_type == 2 or detect_med_type == 0:
|
|
|
if push_type == 0: # ios apns
|
|
|
# self.do_apns(**kwag_args)
|
|
|
- do_apnsss = self.do_apns(**kwag_args)
|
|
|
+ do_apns_code = self.do_apns(**kwag_args)
|
|
|
elif push_type == 1: # android gcm
|
|
|
- self.do_fcm(**kwag_args)
|
|
|
+ do_fcm_code = self.do_fcm(**kwag_args)
|
|
|
elif push_type == 2: # android jpush
|
|
|
- self.do_jpush(**kwag_args)
|
|
|
+ do_jpush_code = self.do_jpush(**kwag_args)
|
|
|
# return JsonResponse(status=200, data={'code': 0, '状态:': push_type})
|
|
|
# 以下是存库
|
|
|
userID_id = up["userID_id"]
|
|
@@ -212,17 +214,21 @@ class NotificationView(View):
|
|
|
if is_sys_msg:
|
|
|
SysMsgModel.objects.bulk_create(sys_msg_list)
|
|
|
Equipment_Info.objects.bulk_create(eq_list)
|
|
|
+
|
|
|
if is_st == '0' or is_st == '2':
|
|
|
print("is_st=0or2")
|
|
|
- return JsonResponse(status=200, data={'code': 0, 'msg': 'success2222222222', 'do_apnsss2' : do_apnsss,'re_list':redis_list})
|
|
|
+ return JsonResponse(status=200, data={'code': 0, 'msg': 'success 0 or 2','do_apns_code': do_apns_code,'do_fcm_code': do_fcm_code,'do_jpush_code': do_jpush_code,'re_list':redis_list})
|
|
|
+
|
|
|
elif is_st == '1':
|
|
|
print("is_st=1")
|
|
|
# Endpoint以杭州为例,其它Region请按实际情况填写。
|
|
|
obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
|
|
|
# 设置此签名URL在60秒内有效。
|
|
|
url = bucket.sign_url('PUT', obj, 7200)
|
|
|
- res_data = {'code': 0, 'img_push': url, 'msg': 'success','do_apnsss1' : do_apnsss,'re_list':redis_list}
|
|
|
+ res_data = {'code': 0, 'img_push': url, 'msg': 'success 1','do_apns_code': do_apns_code,
|
|
|
+ 'do_fcm_code': do_fcm_code,'do_jpush_code': do_jpush_code,'re_list':redis_list}
|
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
+
|
|
|
elif is_st == '3':
|
|
|
print("is_st=3")
|
|
|
# 人形检测带动图
|
|
@@ -234,9 +240,11 @@ class NotificationView(View):
|
|
|
# 设置此签名URL在60秒内有效。
|
|
|
url = bucket.sign_url('PUT', obj, 7200)
|
|
|
img_url_list.append(url)
|
|
|
- res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success', 'do_apnsss3' : do_apnsss,'re_list':redis_list}
|
|
|
+ res_data = {'code': 0, 'img_url_list': img_url_list, 'msg': 'success 3', 'do_apns_code': do_apns_code,
|
|
|
+ 'do_fcm_code': do_fcm_code,'do_jpush_code': do_jpush_code,'re_list':redis_list}
|
|
|
return JsonResponse(status=200, data=res_data)
|
|
|
|
|
|
+
|
|
|
def get_msg_title(self, appBundleId, nickname):
|
|
|
package_title_config = {
|
|
|
'com.ansjer.customizedd_a': 'DVS',
|
|
@@ -314,6 +322,8 @@ class NotificationView(View):
|
|
|
extras=push_data)
|
|
|
push.notification = jpush.notification(android=android)
|
|
|
push.platform = jpush.all_
|
|
|
+ res = push.send()
|
|
|
+ return res
|
|
|
try:
|
|
|
res = push.send()
|
|
|
print(res)
|
|
@@ -343,13 +353,14 @@ class NotificationView(View):
|
|
|
})
|
|
|
print('fcm push ing')
|
|
|
print(result)
|
|
|
- return
|
|
|
+ return result
|
|
|
|
|
|
def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title,
|
|
|
msg_text):
|
|
|
# try:
|
|
|
cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
|
+
|
|
|
push_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}
|
|
|
alert = apns2.PayloadAlert(body=msg_text, title=msg_title)
|