Skip to content

Why doesn't iOSNotificationCalendarTrigger have a weekday property? #331

@KeigoTakamuraSp

Description

@KeigoTakamuraSp

about

Hello everyone

I am trying to implement a weekly notification function with this library, but the Calendar Trigger does not have a day of the week property, so I am considering how to achieve this.

In the near future, I am planning to implement a pseudo-weekly event firing by directly specifying the date and time on the calendar and implementing it with a Time IntervalTrigger, but looking at Apple's documentation, it seems that there is support for this on the OS side, so I wrote this issue as I thought it would be useful if I could do this.

detail

iOS's NSDateComponents implements the weekday property, which allows you to implement weekly notifications.
If you pass it to UNCalendarNotificationTrigger, you can easily implement weekly notifications, which is very helpful...

A randomly written snippet..

        NSDateComponents* date = [[NSDateComponents alloc] init];
        if (data->trigger.calendar.year >= 0)
            date.year = data->trigger.calendar.year;
        if (data->trigger.calendar.month >= 0)
            date.month = data->trigger.calendar.month;
        if (data->trigger.calendar.day >= 0)
            date.day = data->trigger.calendar.day;
        if (data->trigger.calendar.hour >= 0)
            date.hour = data->trigger.calendar.hour;
        if (data->trigger.calendar.minute >= 0)
            date.minute = data->trigger.calendar.minute;
        if (data->trigger.calendar.second >= 0)
            date.second = data->trigger.calendar.second;
        if(data->trigger.calendar.weekday >=1 && trigger.calendar.weekday <8)
            date.weekday = data->trigger.calendar.weekday;

Reference Web page

https://developer.apple.com/documentation/foundation/nsdatecomponents/1410442-weekday?language=objc
https://qiita.com/cloudsnow/items/17eb3b7fa29b67373c73

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions