やってみたNSLog(@"The notifications is \n %@",notification);
ログ メッセージは次のとおりです。繰り返し回数 = UILocalNotificationInfiniteRepeatCount、次の発火日 = 2013 年 10 月 18 日金曜日 12:23:36 PM インド標準時}
やってみたNSLog(@"The notifications is \n %@",notification);
ログ メッセージは次のとおりです。繰り返し回数 = UILocalNotificationInfiniteRepeatCount、次の発火日 = 2013 年 10 月 18 日金曜日 12:23:36 PM インド標準時}
特定の通知を削除する場合
[[UIApplication sharedApplication] cancelLocalNotification: notification];
そして、すべての通知をキャンセルします
[[UIApplication sharedApplication] cancelAllLocalNotifications];
IF が null を返した場合、通知は返されません。代わりにこれを試してください
方法1:
-(void) scheduleNotificationForDate:(NSDate *)date AlertBody:(NSString *)alertBody ActionButtonTitle:(NSString *)actionButtonTitle NotificationID:(NSString *)notificationID{
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.timeZone = [NSTimeZone localTimeZone];
localNotification.alertBody = alertBody;
localNotification.alertAction = actionButtonTitle;
localNotification.soundName = @"yourSound.wav";
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:notificationID forKey:notificationID];
localNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
方法 2:
通知を設定したら、それを編集する唯一の方法は、古い通知をキャンセルして別の通知を作成することなので、この方法で、既存の通知を検索してキャンセルできます。
`for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if([[aNotif.userInfo objectForKey:@"id"] isEqualToString:nId])
{
[[UIApplication sharedApplication]cancelLocalNotification:aNotif];
}
}`