Set repeatInterval in local notification

后端 未结 2 615
猫巷女王i
猫巷女王i 2020-12-11 08:55

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

相关标签:
2条回答
  • 2020-12-11 09:26

    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.

    0 讨论(0)
  • 2020-12-11 09:37

    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.

    0 讨论(0)
提交回复
热议问题