如果用户取消iPhone SDK中的UILocaNotification警报,执行方法



我是iphone编程新手。我在我的应用程序中使用localNotification。它给用户警报,并使用didReceiveLocalNotification响应启动。但我的问题是,如果用户关闭UILocalNotification在我的应用程序中,我需要执行数据库操作。所以我怎么能做到这一点。是否有任何方法为那一个。

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];
}

提前感谢您

据我所知,我们不能做你想做的事。我们只在LocalNotification Alert的"View"选项上有命令。但是如果可能的话,你可以在点击"查看"按钮时做一件事,你可以在这些按钮上显示一个动作表或另一个警报,你可以处理所有你想要的事件。

最新更新