Closed malja closed 6 years ago
Taking a look in the src code (this part was not done by myself) I see that we use the interface ExpirationTime Property. From the official Microsoft documentation, I found:
ExpirationTime Property: Gets or sets the time after which a toast notification should not be displayed.
And also:
The date and time after which the toast is no longer considered current or valid and should not be displayed. Windows attempts to raise toast notifications immediately after you call Show, so this property is rarely used.
Another interesting fact:
For Windows Phone 8.x app: this property also causes the toast notification to be removed from the action center once the specified date and time is reached.
So, it seems that this expiration date has two usages:
When you have a query of notifications, you can avoid the display of some of them if the expiration time is reached.
(Only in Windows Phone 8.x? ): When you show a toast, it aims to remove it from the Action Center when the expiration time is reached.
Third case, not sure if it's possible. But keeping the toast more time visible in the screen should be possible by some how.
So, there is 3 behavior to test & document.
By the way, I saw something strange in the code, the class MyDateTime aims to set up an expiration time by taking the current time (Now) and increasing it with the expiration time. In this in this [line](class MyDateTime : public IReference
_dateTime.UniversalTime = Now() + millisecondsFromNow * 10000;
I think that the idea is to convert the msecs to nanoseconds, so the conversion factor is not correct. I have to check the documentation about the DateTime class.
[EXTRA INFO]
Should check this:
The notifications are grouped on a per-app basis and ordered chronologically inside action center. Each app can have up to 20 notifications in it (older notifications eventually get pushed out by new ones). A toast notification will stay in action center for 7 days until it expires (which will then be removed from action center), unless an earlier expiration time is specified during the creation of the toast.
UPDATE: Taking a look in to the Microsoft documentation about the DateTime class, we have to focus in the FILETIME structure, there we found:
Note that the FILETIME structure is based on 100-nanosecond intervals.
So the conversion is correct.
You are right @malja, after testing:
However after testing, expiration time affects the time notification is shown to user before moved to Action Center. I do not think this is intended
This is not the normal behavior but it's what the lib is doing :S.
[UPDATE]
@malja after a long debugging I found something that can describe the problem.
The expiration time is not related with the time the toast is showed in the screen.
This time is managed by the "duration" field of the XML: https://docs.microsoft.com/en-us/uwp/schemas/tiles/toastschema/element-toast
This parameter can be "short" or "long".
By default is short, but if you add actions to the toast is set up to "long" to give enough time to the user to react to the toast.
Try to launch a notification without actions or with actions to see the differences.
By the way, in the next version I will add a new setter/getter to allow modifications. And some interesting features as the groups/tags. Best regards.
@mohabouje You are right. I apologize. I did some changes to system configuration and thought it was effect of setExpiration method. Nevertheless, as I pointed out in #29, you still may want to allow saving notifications in Action center for each app. On my installation, it was not set by default.
Do you need any help with future update?
@malja Definitely! Feel free to contribute. It's not something requested but it seems to be something interesting. My idea is to add some extra features that are available in modern Windows version like:
Then the library will give you a better way to manage/group your task.
I added short comment on expiration time method and source code example. Required in issue #29.
However after testing, expiration time affects the time notification is shown to user before moved to Action Center. I do not think this is intended.
There are many applications with working notifications. How do they bypass this? Would you please point me to anything more I can do about this?