iOS UILocalNotification显示过去的日期/时间

时间:2023-01-17 19:40:19

I'm trying to present a UILocalNotification with a date/time in the past but, in spite of the fireDate specified, the notification always refers to the time of the delivery. As for the UILocalNotification class reference, In case of fireDate nil or in the past, the notification is delivered immediately. Do you know if there is a way to show a time in the past (instead of "now")?

我正在尝试使用过去的日期/时间来呈现UILocalNotification,但是,尽管指定了fireDate,但通知始终指的是传递的时间。至于UILocalNotification类引用,如果fireDate为nil或过去,通知会立即传递。你知道有没有办法在过去显示时间(而不是“现在”)?

1 个解决方案

#1


0  

This does not work on iOS :( (at least on iOS7.0 this is KO):
Event if the date of the UILocalNotification is set to the past, the notification center shows 'now' instead of 'X min ago' for instance. This is a pity because this can be useful when an event happened when you had no network connection: you were not informed of it, but once you detect it, you may want to apply the real past date value of this event so that when the user is notified of the event on the screen, he knows that it didn't really happened 'now' but maybe '10 minutes ago'.

这在iOS上不起作用:((至少在iOS7.0上这是KO):如果UILocalNotification的日期设置为过去,则通知中心显示“现在”而不是“X分钟前”。这很遗憾,因为当您没有网络连接时发生事件时这可能很有用:您没有被告知它,但是一旦您检测到它,您可能想要应用此事件的实际过去日期值,以便用户会在屏幕上收到有关该事件的通知,他知道它现在并没有真正发生,但可能是“10分钟前”。

The MacOS X equivalent of UILocalNotification is NSUserNotification and handles properly such situation ! https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserNotification_Class/Reference/Reference.html
A difference is made between the deliveryDate (the date of the event, that may be in the past), and the actualDeliveryDate (the date when the event has been delivered / shown to the user). And the date shown on the screen is the deliveryDate

与UILocalNotification相当的MacOS X是NSUserNotification并正确处理这种情况! https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserNotification_Class/Reference/Reference.html在deliveryDate(事件的日期,可能是过去的日期)和actualDeliveryDate(事件传递/显示给用户的日期)。屏幕上显示的日期是deliveryDate

#1


0  

This does not work on iOS :( (at least on iOS7.0 this is KO):
Event if the date of the UILocalNotification is set to the past, the notification center shows 'now' instead of 'X min ago' for instance. This is a pity because this can be useful when an event happened when you had no network connection: you were not informed of it, but once you detect it, you may want to apply the real past date value of this event so that when the user is notified of the event on the screen, he knows that it didn't really happened 'now' but maybe '10 minutes ago'.

这在iOS上不起作用:((至少在iOS7.0上这是KO):如果UILocalNotification的日期设置为过去,则通知中心显示“现在”而不是“X分钟前”。这很遗憾,因为当您没有网络连接时发生事件时这可能很有用:您没有被告知它,但是一旦您检测到它,您可能想要应用此事件的实际过去日期值,以便用户会在屏幕上收到有关该事件的通知,他知道它现在并没有真正发生,但可能是“10分钟前”。

The MacOS X equivalent of UILocalNotification is NSUserNotification and handles properly such situation ! https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserNotification_Class/Reference/Reference.html
A difference is made between the deliveryDate (the date of the event, that may be in the past), and the actualDeliveryDate (the date when the event has been delivered / shown to the user). And the date shown on the screen is the deliveryDate

与UILocalNotification相当的MacOS X是NSUserNotification并正确处理这种情况! https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserNotification_Class/Reference/Reference.html在deliveryDate(事件的日期,可能是过去的日期)和actualDeliveryDate(事件传递/显示给用户的日期)。屏幕上显示的日期是deliveryDate