Read database just before sending a scheduled local notification

erdihuerdihu Member ✭✭

As the title states, I want to read a value from the local database just before sending a scheduled local notification. I was able to achieve this with services on Android but I couldn't find a similar resource to check how it is done on iOS.

Here's my current code. I call this code in FinishedLaunching method in AppDelegate.

// Connect to database and read value
// string title, message = ...

// Create notification
var content = new UNMutableNotificationContent();
content.Title = title;
content.Body = message;
content.Sound = UNNotificationSound.Default;

// Create trigger and make request
// dateComponents is NSDateComponents
var trigger = UNCalendarNotificationTrigger.CreateTrigger(dateComponents, true);

const string requestId = "NotificationService";
var request = UNNotificationRequest.FromIdentifier(requestId, content, trigger);

UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
    if (err != null)

However, this connects to the database directly after opening the application and title and body sections are filled up instantly. The problem is that those values may change over the time, so I need the check them just before the notification is fired. Is there a way to achieve this?

Sign In or Register to comment.