I want to set repeat interval to the value which user selects from date picker.I have date picker of type countdown mode in my application.If user selects 4 hours 15 minutes
I have solved the problem using following code:
-(void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
testDate=notif.fireDate;
NSLog(@"Recieved Notification %@",notif);
[self playSoundWithNotification:notif];
[self _showAlert:@"Alaram" withTitle:@"Daily Achiever"];
}
-(void)_showAlert:(NSString*)pushmessage withTitle:(NSString*)title
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:pushmessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
if (alertView) {
FocusViewController *fvc=[[FocusViewController alloc]initWithNibName:@"FocusViewController" bundle:nil];
[fvc insert:[NSDate dateWithTimeInterval:refTimeIntrval sinceDate:testDate]];
}}
Here testDate and refTimeInterval are variables declared in .pch file.
We cannot set custom Value for repeatInterval
in the UILocalNotification
.
The simplest way you can achieve this by creating a new localNotification
every 4.25 hours and copy the notification details of the the the existing one and delete it while handling the local notification.
Other way is to change the firedate
while handling the local notification.