Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KeigoTakamuraSp opened this issue Dec 11, 2024 · 0 comments
Open

Comments

@KeigoTakamuraSp
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant