How to grab the NEXT fire date from a UILocalNotification object

uilocalnotification objective-c
local notification in ios 10 objective-c
ios local notification when app is in foreground
schedule local notification ios swift 4
user notification swift 4
ios local notification at specific time swift
unmutablenotificationcontent
local notification swift 5

I have a UILocalNotification object that I have setup with repeat intervals day, week, and month. I am having no troubles at all accessing the fire date of the object:

[cell.detailTextLabel setText:[notification1.fireDate description]];

But I am having troubles getting the next fire date. If I print out the above notification1 object to the console, I get this:

<UIConcreteLocalNotification: 0x613e060>{fire date = 2010-11-29 03:53:52 GMT, time zone = America/Denver (MST) offset -25200, repeat interval = 16, next fire date = 2010-11-30 03:53:52 GMT}

This object contains somewhere the value or data I need to display the next fire date...but I can't find it! Does anybody know where I can get it programmatically?

Thanks

I don't think the next fire date is available as a property but rather calculated from fireDate and repeatInterval. Date calculating can be tricky with different time zones and other nasty things. In your example you have chosen a daily repeat and to calculate the next fire date you can do something along the lines of:

NSCalendar *calendar = localNotif.repeatCalendar;
if (!calendar) {
  calendar = [NSCalendar currentCalendar];
}

NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
components.day = 1;
NSDate *nextFireDate = [calendar dateByAddingComponents:components toDate:localnotif.fireDate options:0];

If you use some other repeat interval you would have to change the code accordingly. If you were to use NSMonthCalendarUnit you would have to use components.month = 1 instead.

How to grab the NEXT fire date from a UILocalNotification object, I don't think the next fire date is available as a property but rather calculated from fireDate and repeatInterval . Date calculating can be tricky with different time  In this case, the NotInList event will not fire. To allow the NotInList event to fire, the user should not drop down the combo box list. Example. The following example uses the NotInList event to add an item to a combo box. To try this example, create a combo box called Colors on a form. Set the combo box's LimitToList property to Yes.

fireDate, Swift; Objective-C fireDate. The date and time when the system should deliver the notification. SDKs Declaration. var fireDate: Date? { get set } to schedule a local notification that contains both a region and fire date raises an exception. Web queries are one simple feature in Excel that you can use to import data from any website. You can further automate this process by writing a simple macro using VBA. The example here shows how to extract or read the contents inside an HTML element (any element) from Excel using a simple VBA macro.

i would just add the repeatInterval until the date lies in the future:

-(NSDate*)nextFireDateForNotification:(UILocalNotification*)notification {
        NSCalendar *calendar = notification.repeatCalendar;
        if (!calendar) {
            calendar = [NSCalendar currentCalendar];
        }

        NSDate* date = [notification.fireDate copy];
        while (date.timeIntervalSinceNow > 0) {
            date = [calendar dateByAddingUnit:notification.repeatInterval value:1 toDate:date options:0];
        }
        return date;
    }

iPhone® Application Development For Dummies®, the application uses the fireDate property of the UILocalNotification object to You send yourself the message when you get a location update in location  A second that handles parsing the data into something usable – parse.ps; To get the data from the download.ps to parse.ps you would “pipe” the data in between the two scripts. How to find the Properties and Methods of a PowerShell Object. There are way too many aspects of even the simplest object in PowerShell to remember.

This is in Swift 4 and using calendar's nextDate func.

extension UILocalNotification {

    var nextFireDate: Date? {
        guard let fireDate = fireDate else { return nil }

        let today = Date()
        let cal = Calendar.current

        if fireDate.compare(today) == .orderedDescending {
            return fireDate
        }

        let s: Set<Calendar.Component>
        switch repeatInterval {
        case .year: s = [.month, .day, .hour, .minute, .second]
        case .month: s = [.day, .hour, .minute, .second]
        case .day: s = [.hour, .minute, .second]
        case .hour: s = [.minute, .second]
        case .minute: s = [.second]
        default: return nil // Not supporting other intervals
        }

        let components = cal.dateComponents(s, from: fireDate)
        return cal.nextDate(after: today, matching: components, matchingPolicy: .nextTimePreservingSmallerComponents)
    }

}

Local and Remote Notification Programming Guide: Scheduling and , The steps for configuring a local notification are as follows: After creating the notification content, create a trigger object that defines when to be delivered at a specific date or time, which in this example is the next time the  You can grab helmets and masks and throw them onto your head and face, creating a barrier of protection between you and a barnacle's tendrils. If you're wearing a helmet, the barnacle will scoop

Foundation iPhone App Development: Build An iPhone App in 5 Days , UILocalNotification *reminderNotification; int scheduled = 0; NSDate *fireDate; for (int i it #) { birthday = (BRDBirthday *) fetchedObjects[i]; //if next birthday has past 20) { //get the scheduled reminder date for this birthday from settings fireDate object: self userInfo:nil]; We generate up to 20 scheduled UILocalNotification  The Fire 7 Kids Edition is filled with goodies parents will love, including the subscription-based FreeTime programming with 15,000 books, games and TV shows, as well as a two-year accident forgiveness warranty. Available in three separate colors and 16GB of storage, the Fire 7 features a 7-inch IPS display with up to eight hours of battery life.

Notifications in Xamarin.iOS, Confirming the ability to send a local notification. To schedule a local notification, create a UILocalNotification object, set the FireDate , and schedule it via the UILocalNotification notification = new UILocalNotification(); notification. The following code snippet shows how to get remote notifications: C# Tell the user to input a date in a format. System.out.println(“dd-mm-yyyy”); String date=new Scanner().nextLine(); SimpleDateFormat format=new SimpleDateFormat(“dd-mm-yyyy”); Date date=format.parse(date); Now your string is converted into Date fro

Find out when a repeating UILocalNotification was fired, Here's a helpful link: How to grab the NEXT fire date from a UILocalNotification object And of course, there is the final, fall back solution of parsing the description​  The last lines of code will send the email to our IT email. We use the sp_send_dbmail store procedure to send the email. Recipients will be the email address to receive the email. Profile_name is the name of your mail profile when you configure it. If you do not remember your profile name,

Comments
  • Copy of stackoverflow.com/questions/3984911/…
  • Ok yeah I saw that after I asked my question, but there wasn't an answer...so what was I supposed to do?
  • It's very frustrating that the object clearly knows when the next fire date is but doesn't expose it to you.
  • Hey thank you very much! I think I definitely have a solid direction now
  • This is not a correct answer. This is just adding one component element to the notification initial fire date, it doesn't count the occurrences of repeating notifications occurred.
  • To discourage any future edit suggestions of the same nature, do not edit this post to say it is incorrect and insert a link to a more correct answer. Instead, vote on the posts and leave comments where necessary.
  • @FabrizioProsperi, I don't see where the asker talks about counting the notification occurences. For me this is definitely a good and correct answer.
  • @FabrizioProsperi, ok I see your point. But for me, this is a good answer because it definitely place on the rails toward the solution. Ok, this will not work "as is", but with a little bit of thinking we can easily write an algorithm from his answer. Stackoverflow should not be a place where we just copy-paste code to our production apps.
  • Instead of handling next fire date can we skip the upcoming firing ? and continue on the next repeat time
  • This is almost but not quite - seemingly correct answer is here: stackoverflow.com/questions/20926952/…