Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to get daily notification and for that I have googled and I got some solution from this iPhone : Daily local notifications but I couldn't recognise properly

NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay: 3];
[components setMonth: 7];
[components setYear: 2012];
[components setHour: 6];
[components setMinute: 0];
[components setSecond: 0];
[calendar setTimeZone: [NSTimeZone defaultTimeZone]];
NSDate *dateToFire = [calendar dateFromComponents:components];

Let's say suppose current time is 3:13, and current date is 20-11-2014 in this I want to set local notification at time of 3:14, 20-11-2014 can anybody please help me, because I have tried with following things but not working

    [components setDay: 20];
    [components setMonth: 11];
    [components setYear: 2014];
    [components setHour: 15];
    [components setMinute: 14];
    [components setSecond: 0]; 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
241 views
Welcome To Ask or Share your Answers For Others

1 Answer

 NSDate *date = [NSDate date];
NSDate *newDate1 = [date dateByAddingTimeInterval:60*60*24];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = newDate1;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertBody = [[NSUserDefaults standardUserDefaults] objectForKey:@"NotificationText"];
localNotif.alertAction = @"View";
localNotif.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

try this one hope this may help you. Thank you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...