0

I can be able to send FCM notifications to single or multiple devices through PyFCM instantly.

# Send to single device.
from pyfcm import FCMNotification

push_service = FCMNotification(api_key="<api-key>")

# OR initialize with proxies

proxy_dict = {
          "http"  : "http://127.0.0.1",
          "https" : "http://127.0.0.1",
        }
push_service = FCMNotification(api_key="<api-key>", proxy_dict=proxy_dict)

# Your api-key can be gotten from:  https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging

registration_id = "<device registration_id>"
message_title = "Uber update"
message_body = "Hi john, your customized news for today is ready"
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body)
print result

But I can't find a way to send notification to devices at specific time, say 03-10-2016 16:00:00 .

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274

1 Answers1

1

If you're looking for a public API of FCM for a scheduled push or a payload parameter where you can set the push date, unfortunately, there's nothing like it as of the moment.

You must implement your own App Server and implement the scheduled push yourself (also mentioned it here).


My answer from the tagged duplicate post.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281
  • `or a parameter you can set in the payload that can be modified for the message to be sent for a specific date.`, which parameter in the payload is responsible for holding the date? https://firebase.google.com/docs/cloud-messaging/http-server-ref – Avinash Raj Oct 03 '16 at 07:05
  • @AvinashRaj Unfortunately, there's no such parameter at this moment. – AL. Oct 03 '16 at 07:07
  • Ahm.. Actually, you have to implement your own app server, then make your own implementation (a script or something) to have a message pushed at a specific time/date. – AL. Oct 03 '16 at 07:14
  • that's possible ..like setting up a cron job for every 5 mins, check all the data and send push only certain conditions met.. So this would be the only way... right? No way of making FCM to set the timer.. Why I'm asking is because, If they allow me send message later, I'll run a cron job once for every day.. But if not, I have to run the cron job for every 5 mins.. Hope you understand.. – Avinash Raj Oct 03 '16 at 07:19
  • @AvinashRaj Yup. You can use the Firebase Console, but if you're going to push a lot of scheduled messages, creating a cron job is the way to go. – AL. Oct 03 '16 at 07:23
  • is the scheduling possible through android/ios? – Avinash Raj Oct 03 '16 at 07:30
  • The scheduling via the Firebase console is possible regardless of which client. So long as you make use the Notification payload for iOS (I think), it's all good. – AL. Oct 03 '16 at 07:32