AddHandler for UNUserNotificationCenterMBS

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)
End Sub

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:


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:

Options must be byref!

1 Like

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.