通知の投稿をたくさん読みましたが、どういうわけかどこかで間違っているので、この質問を投稿します。アプリで毎日午前 9 時に通知を受け取りたい。午前 9 時に問題なく受信できますが、問題は午前 2 時にも同じ通知を受信することです。次のコードで試します。誰が私がどこで間違っているのか教えてもらえますか? それともios6の問題ですか?あらゆる種類の助けをいただければ幸いです。ありがとうございました。
NSString *day =@"9:00 AM";
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init]autorelease];
[dateFormat setDateFormat:@"hh:mm a"];
//NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
//[dateFormat setTimeZone:gmt];
NSDate *today=[dateFormat dateFromString:day];
NSLog(@"string %@ & date %@",day,today);
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil)
{
// delObj.QCouter=delObj.QCouter+1;
//[[UIApplication sharedApplication] cancelAllLocalNotifications];
notif = [[cls alloc] init];
notif.fireDate =today;
notif.timeZone = [NSTimeZone systemTimeZone];
NSLog(@"timeZone %@ ",[NSTimeZone systemTimeZone]);
notif.alertBody = @"You have a new letter ";
notif.alertAction = NSLocalizedString(@"View", nil);;
notif.soundName = @"Ding3.wav";
notif.applicationIconBadgeNumber = 1;
notif.repeatInterval = NSDayCalendarUnit;
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"Status"];
NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"You have a notifiaction"
forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
// NSLog(@"userInfo %@",notif.userInfo);
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
[[NSUserDefaults standardUserDefaults] setObject:@"CurrentDay" forKey:@"DayChange"];
}