How to set fromDate in UNTimeIntervalNotificationTrigger

604 Views Asked by At

I need to fire a notification at every 48 hours from a specific date. I can schedule it using UNTimeIntervalNotificationTrigger as -

let trigger : UNTimeIntervalNotificationTrigger = UNTimeIntervalNotificationTrigger.init(timeInterval: TimeInterval(48 * 60 * 60), repeats: true);
let content = UNMutableNotificationContent()   
   // Set the content whatever you want like title, subtitle, sound, userInfo 

let request = UNNotificationRequest(identifier: alertId, content: content, trigger: trigger);

My problem is how to set the fireDate. I need to start this notification from a future date but using it, it is started from today.

I also tried using UNCalendarNotificationTrigger(using component [.hour, .minute]) but it repeats every day as particular hour and minute matches every day. I also followed other solutions of stack overflow but still don't get any solution.

0

There are 0 best solutions below