I want to add the event willPresentNotification for UNUserNotificationCenterMBS with AddHandler. But I can’t figure out why I get a syntax error.
I made a property:
Private Property UNUserNotification As UNUserNotificationCenterMBS
In the constructor of the class I have:
UNUserNotification = new UNUserNotificationCenterMBS
AddHandler UNUserNotification.willPresentNotification, AddressOf PresentNotification
This makes some syntax errors:
What is wrong with my code?
Your method declaration is what?
You may not have the right parameters.
Here is the method:
Private Sub PresentNotification(notification as UNNotificationMBS)
Well… there’s your problem. The error says that the delegate needs to take three parameters:
UNUserNotificationCenterMBS, UNNotificationMBS, Integer
And your method only has one:
UNNotificationMBS and UNUserNotificationCenterMBS look the same to me.
I’ve change the method for the AddHandler to
Private Sub PresentNotification(NotificationCenter as UNUserNotificationCenterMBS, theNotification as UNNotificationMBS, Options as Integer)
Now I get the following error:
Must have had a senior moment today. Got the event working. Is it a bug that the event happens 2 times? I’ve added a time check but then I get no notifications.