Cancel UILocalNotification

后端 未结 10 917
余生分开走
余生分开走 2020-11-27 12:53

I have a problem with my UILocalNotification.

I am scheduling the notification with my method.

- (void) sendNewNoteLocalReminder:(NSDate *)date  a         


        
10条回答
  •  渐次进展
    2020-11-27 13:37

    My solution is to archive UILocalNotification object you have scheduled with NSKeyedArchiver and store it somewhere (in a plist is preferred). And then, when you want to to can cancel the notification, look up the plist for the correct data and use NSKeyedUnarchiver to unarchive. The code is pretty easy:

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:notice];
    

    and

    UILocalNotification *notice = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    

提交回复
热议问题