iOS 6.1.3でいくつかのテストを実行しました。ここに私が持っているものがあります:
私はシアトル、午後1時(太平洋夏時間、GMT-7)です。シアトル(太平洋夏時間で作成した通知の
notification1 = [[UILocalNotification alloc] init];
notification1.fireDate = fireDate;
// notification1.timeZone is nil by default
NSLog(@"%@", notification1);
notification2 = [[UILocalNotification alloc] init];
notification2.fireDate = fireDate;
notification2.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSLog(@"%@", notification2);
notification3 = [[UILocalNotification alloc] init];
notification3.fireDate = fireDate;
notification3.timeZone = [NSTimeZone defaultTimeZone];
NSLog(@"%@", notification3);
ログ:今私は
fireDate = 2013-08-31 19:00:00 +0000 (2013-08-31 12:00:00 -0700)
は、その後、私が作成したとの通知を予定してい
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
// 2013-08-31 @ 12:00:00 (noon)
dateComponents.year = 2013;
dateComponents.month = 8;
dateComponents.day = 31;
dateComponents.hour = 12;
dateComponents.minute = 0;
dateComponents.second = 0;
NSDate *fireDate = [gregorianCalendar dateFromComponents:dateComponents];
:私はNSDate
を作成しました、GMT-7):
notification1:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = (null),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time
notification2:
fire date = Saturday, August 31, 2013, 7:00:00 PM GMT,
time zone = GMT (GMT) offset 0,
next fire date = Saturday, August 31, 2013, 7:00:00 PM Pacific Daylight Time
notification3:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = US/Pacific (PDT) offset -25200 (Daylight),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time
電話のタイムゾーンをシカゴに変更しました。現在は午後3時(中央夏時間、GMT-5)です。通知の
ログ、シカゴ(中部夏時間、GMT-5)に
notification1:
fire date = Saturday, August 31, 2013, 2:00:00 PM Central Daylight Time,
time zone = (null),
next fire date = Saturday, August 31, 2013, 2:00:00 PM Central Daylight Time
notification2:
fire date = Saturday, August 31, 2013, 7:00:00 PM GMT,
time zone = GMT (GMT) offset 0,
next fire date = Saturday, August 31, 2013, 7:00:00 PM Central Daylight Time
notification3:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = US/Pacific (PDT) offset -25200 (Daylight),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Central Daylight Time
結論:UILocalNotification timeZone
がnilのとき
- は、火災日は時間に固定されています。つまり、通知はGMT-7の午後12時、GMT-5の午後2時、またはGMTの午後7時に開始されます。
- UILocalNotification
timeZone
をGMTに設定すると、GMT時間の発射日が計算され、ユーザーが別のタイムゾーンに移動すると自動更新されます。この例では、時刻12:00 GMT-7は19:00 GMTに変換され、通知は19:00 GMT、19:00 GMT-5または19:00 GMT-5のいずれのタイムゾーンであってもローカル時間19:00に設定されています。 19:00 GMT-7)。
- UILocalNotification
timeZone
がローカルタイムゾーン(太平洋夏時間、GMT-7)に設定されている場合、発射日は現地時間で計算され、ユーザーが別のタイムゾーンに行くと自動更新されます。この例では、時刻は12:00 GMT-7であったため、通知は12:00 GMT、12:00 GMT-5または12:00 GMT- 7)。
驚くばかりです。技術的には正午ではなく午後7時にこれをスケジュールしましたが、質問にもちょうど答えます。 –
誰も、iOS 10のUNNotificationトリガの日付に関する同様の調査をしていますか? – Jonny
@ジョニー私はあまりにもそれが不思議です。タイムゾーンを設定すると違いはありません。 – David