0


I am not sure if there is a way to show today widgets only on certain days. I have checked in the developer libraries and could not find any method or function to refer to in this situation. It would be great if there was some API or Framework that could do this.
Thank you so much!

Maanit
  • 316
  • 2
  • 4
  • 14

1 Answers1

0

Well I don't know about trying to get the actual widget target to appear or not in Notification Center. That is down to the user, you can't control that.

But what you can control is what is presented in your widget (not whether the widget is there or not).

You can then use NSDate to get the current date and then do some checks. If the date is what you want, then you can set your widget to show/hide certain objects.

For example:

NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy"];
NSString *dateString = [dateFormat stringFromDate:today];
NSLog(@"date: %@", dateString);

if ([dateString isEqual:@"25/12/2015"]) {
    NSLog(@"Its Christmas!!!");
    // Now show/hide certain objects such as labels/etc....
}

Hope this helps :)