推送通知无法使用推送通知时间

时间:2018-05-18 13:08:10

标签: python django python-2.7 django-forms pyfcm

当我在python中使用推送通知时,我无法根据需要发送推送通知时间

示例:1米或60米等

我在应用程序中使用https://github.com/olucurious/PyFCM

请举例说明如何根据需要发送推送通知时间

registration_id = request.POST['registration_id']
message_title = request.POST['message_title']
message_body = request.POST['message_body']
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)

我们需要为此应用程序发送推送通知类型当我设置时间然后得到这么多问题并且示例不在整个示例中退出。

完整示例:

def index(request):
    if (request.POST['type'] == 'android'):
        push_service = FCMNotification(api_key="abc.pem")
        registration_id = request.POST['registration_id']
        message_title = request.POST['message_title']
        message_body = request.POST['message_body']
        result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
        print result
        return HttpResponse("Hello Testing, world. You're at the tesing index.")
    else:
        apns = APNs(use_sandbox=True, cert_file='abc.pem', enhanced=True)
        token_hex = request.POST['registration_id']
        messageTitle = request.POST['message_title']
        dict = {'title': request.POST['message_title'], 'body': request.POST['message_body']}
        payload = Payload(alert=dict, sound="default", badge=1)
        apns.gateway_server.send_notification(token_hex, payload)
        frame = Frame()
        identifier = 1
        expiry = time.time()+3600
        priority = 10
        frame.add_item(request.POST['registration_id'], payload, identifier, expiry, priority)
        return HttpResponse("Hello Testing, world. You're at the tesing index second")

0 个答案:

没有答案