0

This code is working as expected, but all the notifications sent are set default expiry time (28 days).

from pyfcm import FCMNotification
push_service = FCMNotification(api_key="<api-key>")
data_message = {"foo":"bar"}
result = push_service.notify_single_device(registration_id=registration_id, data_message=data_message)

How can I set the expire time to less than default so very old notifications dont make their way to the users devices?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Ezequiel Adrian
  • 726
  • 1
  • 11
  • 29

1 Answers1

1

Taking a look at the PyFCM documentation on GitHub I could find the solution:

time_to_live (int, optional): How long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks. Defaults to None which uses the FCM default of 4 weeks.

Example implementation to set notification to expire after 1 hour if not delivered:

push_service.notify_single_device(registration_id=registration_id, data_message=data_message, time_to_live=3600)
Ezequiel Adrian
  • 726
  • 1
  • 11
  • 29