Hariprasad.J
Hariprasad.J

Reputation: 307

Execute method if user cancel the UILocaNotification alert in iPhone SDK

I am new to iphone Programming . I am using localNotification in my application.It is giving alert to user and responding to Launch using didReceiveLocalNotification.But my problem is if user close the UILocalNotification in my Application i need to execute database operation .So how can i do that .Is there any approach for that one.

UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
    NSDate* now = [NSDate date];
    [localNotification setFireDate:now];
    localNotification.soundName=@"Tink.wav";

    [localNotification setAlertAction:@"Launch"]; 
    [localNotification setAlertBody:@"You have entered to Your Place:"]; 
    [localNotification setHasAction: YES]; 
    NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"obj" forKey:kRemindMeNotificationDataKey];
    localNotification.userInfo = userDict;



- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    NSLog(@"Recieved Notification");

    NSString *DateString=[notif.userInfo valueForKey:kRemindMeNotificationDataKey];
    if([DateString isEqualToString:@"obj"])
    { 
        [[UIApplication sharedApplication] cancelLocalNotification:notif];
    }

    NSString *strNotif=[notif.userInfo objectForKey:kRemindMeNotificationDataKey];
if ([strNotif isEqualToString:@"obj"]) {
    UIAlertView *alretCheck=[[UIAlertView alloc]initWithTitle:@"notifi Testing in DidRec+" message:strNotif  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alretCheck show];
    [alretCheck release];
}

Thanking you in advance.

Upvotes: 0

Views: 278

Answers (1)

mAc
mAc

Reputation: 2514

Now Acc. to my Knowledge we cannot do that what you want. we only have command on the "View" Option of LocalNotification Alert. But if possible u can do one thing onClick on "View" button u can Show an ActionSheet or another alert and on those buttons you can handle all the event you want.

Upvotes: 3

Related Questions