PhoneGap iOS LocalNotifications夏令时 [英] PhoneGap iOS LocalNotifications Daylight Savings
问题描述
我在使用(臭名昭着的) iOS中的Drew Dahlman的Phonegap本地通知 。 < em>工作。
我从来没有写过一行 objective-c (这可能是为什么我现在有麻烦了)但我认为插件不工作正常,并希望尽可能解决它。
当我设置一个通知今天在13:00它火灾正确。但是,当夏令时播放时,通知会在14:00(一小时后)发出。
这是因为时区不在考虑范围内吗? Drew提到时区设置为+0000不是一个问题,但这是错误的信息?我应该更新插件来处理时区和夏令时吗?或者在我自己的代码中处理夏令时,只是在DST活动时设置日期-1小时?
我想我必须更新第二行> LocalNotification.m ,但正如我所说,我不确定要更新的内容。
UILocalNotification * notif = [[UILocalNotification alloc] init];
notif.timeZone = [NSTimeZone defaultTimeZone];
Ah似乎有一个奇怪的问题
示例1:当我这样做时,
duedate
是2013-04-08T21:30的值 var d = new Date(duedate)。 getTime();
d = new Date(d);
plugins.localNotification.add({
date:d,
...
通知记录为设置为21:30,如下所示:
通知设置: 04-08 21:30:00 +0000
示例2: c> duedate 这样:(现在的时间是21:30)
var d = new Date()。getTime();
通知记录为设置为20:30,像这样:
通知集:2013-04-08 20:30:00 +0000
但在第二个示例中,由于节省了日光,通知在21:30发出。
解决方案(排序)
我要添加或减去现在和我想要的时间之间的时间差通知火,而不是专门设置日期。
I'm using (the infamous) Drew Dahlman's Phonegap Local Notifications in iOS. And it seems to work.
I have never written a line of objective-c and would prefer not to (which is probably why I'm having trouble now!) but I think the plugin is not working quite right and would like to fix it if possible.
When I set a notification for today at 13:00 it fires correctly. However when daylight savings is in play the notification fires at 14:00, an hour late.
Is this because timezones are not being taken into account? Drew mentions that the timezone being set to +0000 is not a problem, but is this mis-information? Should I update the plugin to handle timezones and daylight savings? Or handle daylight saving in my own code and simply set the date -1 hour when DST is active?
I think I have to update the second of these lines in LocalNotification.m but as I said I am unsure of what to update it to.
UILocalNotification *notif = [[UILocalNotification alloc] init];
notif.timeZone = [NSTimeZone defaultTimeZone];
Ah there seems to be a bit of a strange issue when notifications are set.
Example 1:
When I do something like this, where duedate
is a value of 2013-04-08T21:30
var d = new Date(duedate).getTime();
d = new Date(d);
plugins.localNotification.add({
date: d,
...
The notification is logged as being set for 21:30, like so:
Notification Set: 2013-04-08 21:30:00 +0000
Example 2: if I set the duedate
like this: (where the time now is 21:30)
var d = new Date().getTime();
The notification is logged as being set for 20:30, like so:
Notification Set: 2013-04-08 20:30:00 +0000
However in the second example the notification fires at 21:30, due to day light savings.
Solution (of sorts)
I'm going to have to add or subtract the difference in time between now and when I want the notification to fire, rather than set the date specifically.
这篇关于PhoneGap iOS LocalNotifications夏令时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!