Local notice every 2 weeks

link1 link2

If I want the local notification to be repeated every 2 weeks, how can this be done?

I read a few questions and answers here, they mentioned to transfer the local notification, but how to transfer the local notification when the application is in the background?

I would appreciate any help on the same.

Thank.

0
source share
1 answer

To migrate using UILocal Notification,

NSDateFormatter *dat= [[NSDateFormatter alloc]init];
[dat setLocale:[NSLocale currentLocale]];
[dat setTimeZone:[NSTimeZone systemTimeZone]];

//[dat setDateFormat:@"YYYY-MM-dd"];// YYYY-MM-dd hh:mm a
//NSString *dateM=[dat stringFromDate:datM];
//[dat setDateFormat:@"YYYY-MM-dd h:mm a"];
NSDate *reminderDate=[NSDate date];
//Use manual option too for timing    
reminderDate =[reminderDate dateByAddingTimeInterval:1*24*60*60*7];


UILocalNotification  *localnoification = [[UILocalNotification alloc]init];
localnoification.fireDate=reminderDate;
localnoification.timeZone = [NSTimeZone defaultTimeZone];
localnoification.alertBody = word;
localnoification.alertAction = @"Tap to see word of the day";
//May Add Custom Sound Also
//localnoification.soundName = UILocalNotificationDefaultSoundName;

localnoification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

//localnoification.applicationIconBadgeNumber = 1;
localnoification.repeatInterval = NSDayCalendarUnit;

[[UIApplication sharedApplication] scheduleLocalNotification:localnoification];
0
source

Source: https://habr.com/ru/post/1654015/


All Articles