2016-07-18 12 views
0

i lokale Benachrichtigung an jedem Samstag wie diese,zeigen lokale Benachrichtigung an bestimmtem Tag und bestimmte Zeit in iOS

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
     [email protected]"EEEE"; 
     NSString *dayString = [[dateFormatter stringFromDate:[NSDate date]] capitalizedString]; 
     NSLog(@"day: %@", dayString); 

     if([dayString isEqualToString:@"Saturday"]) 
     { 
      NSLog(@"Success"); 
      [self PushNotification]; 
     } 
-(void)PushNotification 
{ 
     UILocalNotification* localNotification = [[UILocalNotification alloc] init]; 
     localNotification.alertTitle = @"Test"; 
     localNotification.alertBody [email protected]"test of notification"; 


     NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; 
     NSDateComponents *componentsForFireDate = [calendar components:(NSCalendarUnitYear | NSCalendarUnitWeekOfMonth | NSCalendarUnitHour | NSCalendarUnitMinute| NSCalendarUnitSecond | NSCalendarUnitWeekday) fromDate: [NSDate date]]; 
     [componentsForFireDate setWeekday: 7]; //for fixing Saturday 
     [componentsForFireDate setHour: 17]; //for fixing 5PM hour 
     [componentsForFireDate setMinute:0]; 
     [componentsForFireDate setSecond:0]; 

     localNotification.repeatInterval = NSCalendarUnitWeekOfMonth; 
    } 

aber meine lokale Benachrichtigung Anzeige in jedem minit zeigen will, wie kann ich dann Benachrichtigung auf jeder Anzeige Samstag der Woche. danke.

Antwort

0

Try fireData Eigenschaft in localNotification und planen Sie Ihre Mitteilung

localNotification.fireDate = componentsForFireDate.date; 
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

Hope this Hilfe

+0

ya ich bereits registrieren lokale Benachrichtigung zu erklären. – Rock

+0

mein Problem ist die Anzeige der Benachrichtigung in jeder Minute ich möchte Anzeige Benachrichtigung einmal pro Woche. – Rock

+0

Sie müssen eine FireDate-Eigenschaft erklären, die es jeden Samstag gleich – iSashok