首页 > 解决方案 > 推送通知不适用于推送通知时间

问题描述

当我在 python 中使用推送通知时,我无法按要求发送推送通知时间

示例:1m 或 60m 等

我在应用程序中使用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")

标签: pythondjangopython-2.7django-formspyfcm

解决方案


推荐阅读