Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat HMTimerTrigger On multiple days (Ex: Every Monday,Wednesday.... like in iOS 10 Home app)

I have checked the iOS 10 Home app. The screenshot is captured from Home app only.

enter image description hereSince last 2 days I have been trying to implement the HMTimerTrigger repeat functionality. My requirement is I have to repeat the Trigger on every monday,tuesday and friday. What I found is I can add only one day(Monday or Tuesday ... but not Monday AND Tuesday) like below.

  unsigned flags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekOfYear | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute;
  NSDate *fireDate = [NSDate date];
  NSDateComponents *recurrenceComponents = [[NSDateComponents alloc] init];
  recurrenceComponents.weekday = 2; // For monday

  NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:flags fromDate:fireDate];
  fireDate = [[NSCalendar currentCalendar] dateFromComponents:dateComponents];

  HMTimerTrigger *trigger = [[HMTimerTrigger alloc] initWithName:triggerName.text
                                                          fireDate:fireDate
                                                          timeZone:nil
                                                        recurrence:recurrenceComponents
                                                recurrenceCalendar:[NSCalendar currentCalendar]];

Thank you for reading my post. Any ideas/suggestions would be very helpful.

like image 259
SRI Avatar asked Aug 12 '16 07:08

SRI


1 Answers

This functionality is not available to the public even though Apple has it in their HomeKit app. The best you could do is create multiple triggers for each day but then the user would gets confused.

Please open up a radar bug on it here

like image 59
Maria Avatar answered Nov 17 '22 21:11

Maria