开发者

How to call the snooze feature on local notification in iOS?

I am implementing an alarm application in iOS with snooze feature.

Local notification is set properly. When I select a particular time it fires at that particular time displaying 2 buttons close and view.

I have renamed the view button as snooze so that when the user c开发者_如何学Clicks on snooze the notification will get repeated after 1 mins.

But I have a problem when the snooze button is clicked it shows properly in the console that it will repeat after 1 min from current time but the notification does not repeat in the console.

What may be the problem.

Please help me in solving this problem.

This is my code:-

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{   
    NSLog(@"Recieved local Notifications %@",notification.fireDate); 
    NSDate *date=[notification.fireDate dateByAddingTimeInterval:60]; 
    NSLog(@"date After interval is %@",date); 
    
    UILocalNotification *notif=[[UILocalNotification alloc]init]; 
    notif.fireDate=date; 
    NSLog(@"new notification:%@",notif.fireDate);
        [[UIApplication sharedApplication] scheduleLocalNotification:notif];
    
    
    application.applicationIconBadgeNumber = 0;
}

In the didReceiveLocalNotification I have added because when the snooze button is clicked I want the 1 minute time interval notification to be set and called.


You're initializing a new UILocalNotification, but you not setting anything to be done when it actually fires - no body, or action.

From the Apple documentation,

alertBody - The default value is nil (no alert).

So, when the notification fires there will be no outward alert.

Are any of the application Local Notification callbacks being invoked? (which one, depends on the state of the App)


when ever your got notification application responds to below method so.put one alertview you got alarm .did you want snooze . then by that time remove all before notification and recreate notification. with repeat interval.

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{

//write alert in alert delegate method create new notification object ,



}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜