Push Notification not working with push notification time

203 Views Asked by At

When I am using push notification in python then I am not able to sent push notification time as per required

Example : 1m or 60m etc

I am using https://github.com/olucurious/PyFCM this in application.

Please give me example how to send push notification time as per required

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)

Where we need to sent push notification type for this application When I am setting time then getting so many problems and example not exit in whole example.

Full Example:

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

There are 0 best solutions below