最近在做IOS 版 的VOIP 功能
NSArray * array = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (UILocalNotification * loc in array) {
NSDictionary *dic = loc.userInfo;
NSString* currPin = [dic objectForKey:kVoipPinKey];
if([currPin isEqualToString:pin]){
[[UIApplication sharedApplication] cancelLocalNotification:loc];
}
}
无法生效的问题。
- (void)saveLocalNotification:(NSString*) pin notification:(UILocalNotification*)notification {
NSUserDefaults* defaults =[NSUserDefaultsstandardUserDefaults];
NSString* userDefKey = pin;
NSData* dataEnc = [NSKeyedArchiverarchivedDataWithRootObject:notification];
[defaultssetObject:dataEncforKey:userDefKey];
}
UILocalNotification* loc =[[UserInfoStoragesharedUserInfoStorage]clearLocalNotification:pin];
if(loc){
[[UIApplicationsharedApplication]cancelLocalNotification:loc];
}