|
@@ -71,11 +71,10 @@ class Test(View):
|
|
|
def do_fcm_push(self, request):
|
|
|
rg_id = request.GET.get('rg_id', '')
|
|
|
serverKey = request.GET.get('serverKey', '')
|
|
|
+ push_type = request.GET.get('push_type', '')
|
|
|
# Send to single device.
|
|
|
from pyfcm import FCMNotification
|
|
|
|
|
|
- push_service = FCMNotification(api_key="<api-key>")
|
|
|
-
|
|
|
# OR initialize with proxies
|
|
|
|
|
|
# proxy_dict = {
|
|
@@ -94,9 +93,15 @@ class Test(View):
|
|
|
"received_at": now_time, "sound": "sound.aif", "uid": "XFDJUHUIOKJHYTGSFFDR", "zpush": "1"}
|
|
|
# message_body = json.dumps(data)
|
|
|
|
|
|
- message_body = '警告:Motion Channel:1 日期:{tt}'.format(tt=str(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))))
|
|
|
- result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
|
|
|
- message_body=message_body,data_message=data)
|
|
|
+ message_body = '警告:Motion Channel:1 日期:{tt}'.format(
|
|
|
+ tt=str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))))
|
|
|
+ if push_type:
|
|
|
+ result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
|
|
|
+ message_body=message_body, data_message=data)
|
|
|
+ else:
|
|
|
+ result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
|
|
|
+ message_body=message_body)
|
|
|
+
|
|
|
from var_dump import var_dump
|
|
|
var_dump(result)
|
|
|
|