Xcode4 UILocalNotification无用户信息
我尝试取消本地通知。我附上一份带有Id的dict,以便以后查找:Xcode4 UILocalNotification无用户信息,xcode4,ios4,ios5,automatic-ref-counting,Xcode4,Ios4,Ios5,Automatic Ref Counting,我尝试取消本地通知。我附上一份带有Id的dict,以便以后查找: + (void) send:(NSString*)title actionText:(NSString *)actionText when:(NSDate *)when count:(NSInteger)count option:(NSDictionary *)options { UILocalNotification *notif = [[UILocalNotification alloc] init]; //
+ (void) send:(NSString*)title actionText:(NSString *)actionText when:(NSDate *)when count:(NSInteger)count option:(NSDictionary *)options
{
UILocalNotification *notif = [[UILocalNotification alloc] init];
//Setup code here...
notif.userInfo = options;
ALog(@"Sending notification %@ %@", notif.alertBody, notif.userInfo);
//Print: Sending notification Task Col 0 0 {id = "1-1"};
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
然后,当我试图找到它时:
+ (void) cancelNotification:(NSString *)theId {
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if([[aNotif.userInfo objectForKey:@"id"] isEqualToString:theId])
{
// Never come here: userInfo is nil!!!
}
}
}
用户信息始终为零。我发了一份口述:
NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
[info setObject:theId forKey:@"id"];
或
同样的结果。ID为NSString本地通知仅有效,它具有有效的时间戳。因此,在创建时,请确保它具有有效的时间戳。因此,它将出现在UIApplication的附表通知中 请让我知道你的意见
例如:localNotification.fireDate=[NSDate日期] 本地通知仅有效,它具有有效的时间戳。因此,在创建时,请确保它具有有效的时间戳。因此,它将出现在UIApplication的附表通知中 请让我知道你的意见 例如:localNotification.fireDate=[NSDate日期]
[NSMutableDictionary dictionaryWithObject:theId forKey:@"id"]