First off I am not very familiar with do statements but I think they can be used just like a action button. My code below is a alarm. All I wanted to do is when the alarm goes off for the notification to appear. Thats it. Right now the alarm goes off (successT is printed in log file) the notification does not appear.
do statements are not like action buttons – all it does is introduce a new scope such that any new names you introduce via let or var cannot be seen outside of its close curly brace. The most common way to use them is with the optional catch clauses for exception handling. By itself, do doesn’t do much.
The issue you are having is that notifications are not shown (by default) while the app is in the foreground. It is expected that the app itself uses its own UI to alert the user. Notifications are for when your app is not in the foreground.
But, if you are not in the foreground, then testDate() is not going to be called. For an alarm, the thing to do is to set the UserNotification to the point in the future when you want it to go off – then if you are not running, the notification will be sent. So don’t make it at the point it’s supposed to go off – make the notification object when the user sets the time (and use timeInterval to be that time)