Reputation: 816
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?
Upvotes: 0
Views: 629
Reputation: 816
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)
Upvotes: 1