I am making a Calendar app where the user can schedule events.
The problem: User creates an event that repeats every week/day/month/year. I need to schedule a notification for every week/day/month/year at that date forever using the OneSignal API
What I’ve done
✅ Created normal scheduled notifications with POST requests and API
✅ Found a similar method using another plugin:
await flutterLocalNotificationsPlugin.showDailyAtTime(2, 'notification title', 'message here',
time, platformChannel,payload: 'new payload'));
I would need to translate this but using OneSignal.
What do I need?
- Find an option in OneSignal API to setup a recurring scheduled notification [Should be possible]
- In the case this is not possible, some logic or guidance as to how to schedule infinite possible notifications.
3
Answers
I have faced this issue, and I couldn’t find any way to schedule notifications via OneSignal API.
What I did was I created an express API and added an endpoint to create a cron job to schedule the notification sending via one signal REST API.
I think there is no direct solution,but yeah you can able to get this functionality by updating your code like this,
also for more info, you can find it out here this link describe other functionality as well
edited 1:- one more suggestion is you can use "delayed_option" and "daily" for Recurring notifications according to your situation
I found this in here
Based on my own knowledge, there isn’t a direct solution to schedule recurring notifications using OneSignal API but you can make something:
First, make sure you have all the dependencies:
Then use a function like this to schedule daily notifications (make sure to update APIs)
Then call the function
This will schedule a daily notification starting one minute from the time of scheduling.
This solution can be suitable for daily recurring notifications and you may need to use a similar approach for weekly/monthly/yearly notifications by modifying the delayed_option and delivery_time_of_day values in the request.
For the scalability issue, I would create a backend service with an endpoint that creates a cron job to schedule the notification sending via OneSignal.