I am having troubles setting up a weekly repeating local notification with dynamic/changing content data.
Although I can create a scheduled notification for a specific day that repeats, but in my case with the “disadvantage” that the content data is static, since I would like to display a different/random quote (that I have in a locally stored json) each week.
Is there any way to update the content data before the notification is executed, as I have not found a suitable solution in the documentation?
Maybe a callback function would be useful, which would run before the notification is executed regardless of whether it’s in the background or foreground to change the content data?
I think we discussed this one on Discord, but for the sake of anyone else visiting the forums, you can’t update an existing scheduled notification, but you can cancel and reschedule them. So, you could write a function that would cancel and reschedule notifications to deliver quotes X days out, and then a) execute it when your app goes active (using
AppState), and then find a way to execute it periodically in case the app isn’t foregrounded soon enough. This could be as simple as scheduling a final notification that tells the user to open the app to get more quotes (if they keep opening the app in time, this would just keep getting scheduled further into the future), or using background tasks or remote notifications to trigger code when your app is backgrounded.