Dynamic conditional notifications


#1

Hello,
in my app I use sqlite to save items with a date and I need, everyday, to check if there are items from db with “date = today” and if there are, show a notification with a custom message, also if app is not running.

My idea at this time is to create a local notification at item date when it is created and, if a notification at that date already exists, the system will update it editing the badge and the text. The (boring) problem is that I want allow user to choose how many days before show the notification, so if he choose 3 days, I have to delete all notifications and recreate them changing the dates.

To avoid this, I thought to create an interval at every hour in background mode to check items, but I read that in latest versions of iOS apps in background are limited and I think the timer would take a bit of memory of the phone.

What do you think is the best approach?
Anyway, I would use local and not push notifications because the app has offline support and the “online” one is only to save data in the cloud.


#2

Hi, did You find the way to do that because I have the same problem :confused:


#3

I’m just scheduling them at the specified date and, when a I remove the item from database, I refetch all the items of that day, remove current notifications of that day and reschedule them. It sucks, but works


#4

OK, can You share Your code with me how did You do that?
I have found this post by searching https://www.joshmorony.com/getting-familiar-with-local-notifications-in-ionic-2/
here is explained somehow how to do that, but I would like to see how did You do that.