gpt4 book ai didi

ios - 通知在凌晨 12 点而不是早上 7 点发送

转载 作者:行者123 更新时间:2023-11-29 13:15:13 26 4
gpt4 key购买 nike

我正在尝试安排在早上 7 点发送通知。但它会在凌晨 12 点送达。请帮助我我做错了什么。这是我的代码。

NSString *date = @"4/14/2013 07:00";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy HH:mm"];
NSDate *thisDate = [df dateFromString:date];

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = thisDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"This is notification";
localNotification.alertAction = @"view";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertLaunchImage = Nil;
self.badgeCount ++;
localNotification.applicationIconBadgeNumber = self.badgeCount;
localNotification.userInfo = Nil;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

我预计此通知会在早上 7 点送达。相反,它会在凌晨 12 点弹出。这里出了什么问题?

最佳答案

我敢打赌 localNotification.timeZonedf.timeZone 不一样...

将此添加到您的 DateFormatter:

df.timeZone = [NSTimeZone defaultTimeZone];

关于ios - 通知在凌晨 12 点而不是早上 7 点发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16004537/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com