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?
Blockquote
Your method declaration is what?
You may not have the right parameters.
Here is the method:
Private Sub PresentNotification(notification as UNNotificationMBS)
End Sub
Greg_O
(Greg O)
April 30, 2023, 10:03am
4
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
1 Like
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.