相关疑难解决方法(0)

取消UILocalNotification

我的UILocalNotification有问题.

我正在使用我的方法安排通知.

- (void) sendNewNoteLocalReminder:(NSDate *)date  alrt:(NSString *)title
{
    // some code ...
    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

    if (localNotif == nil)  
        return;

    localNotif.fireDate = itemDate; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertAction = NSLocalizedString(@"View Details", nil); 
    localNotif.alertBody = title;
    localNotif.soundName = UILocalNotificationDefaultSoundName; 
    localNotif.applicationIconBadgeNumber = 0;

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:stringID forKey:@"id"]; 
    localNotif.userInfo = infoDict; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
    [localNotif release];
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,我正确收到通知.问题是我应该取消通知.我正在使用这种方法.

- (void) deleteNewNoteLocalReminder:(NSString*) reminderID noteIDe:(NSInteger)noteIDE
{
    [[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)notification ????  
}
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么做,但我的问题是:

我如何知道应删除哪个UILocalNotification对象?
有没有办法列出所有通知?

我唯一拥有的是我应删除的提醒ID.
我正在考虑将UILocalNotification对象保存在我的"Note"对象中并以此方式获取,当我保存到我的SQLite数据库时序列化对象等等......是否有更聪明的方法?

iphone notifications cocoa-touch ios4

48
推荐指数
5
解决办法
4万
查看次数

标签 统计

cocoa-touch ×1

ios4 ×1

iphone ×1

notifications ×1