It's probably similar to INotificationFormatter that is registered inside internal classes. I haven't tried this myself, but remembered this discussion, it might be helpful:
Im interested in this aswell.
I have my custom provider ( post to slack) and whenever any notification happens, I want it into a slack channel. Somehow we cannot add/hook into the built in user notification provider.
About the subscription. seems we need to handle that ourselves too. Would be nice if episerver extended "my settings" and added subscription handling there.
Any lights on this would be appreciated.
I demoed this last year, so the API might have changed slightly, but what I suspect is missing is a Formatter for a custom channel name. Then binding your Provider to the same channel name, and supplying a conversion between a username and what the provider wants as recipients (e.g. an email adress). How to write a formatter is in the documentation, but we'll update with an example on registering a provider for a channel name. In the meantime, here's an example:
// Get preference register var preferencesRegister = context.Locate.Advanced .GetInstance<INotificationPreferenceRegister>(); // Register a provider to handle your custom channel preferencesRegister.RegisterDefaultPreference( "my-custom-channel-name", "MyProvider", username => GetEmailExampleMethod(username));
Here is the demo code on Github. You're probably most interested in IftttNotificationProvider.cs, NotificationFormatter.cs, and NotificationInitialize.cs.
Instead of "my-custom-channel-name", can we jack into episerver's default channel name? Whenever a new NotificationMessage() is created without specified channelName, it will pop up in edit mode. I want that message to, so I get all episerver messages to my provider.
If there's no channel name it goes, as you said, directly to the UI. So you can't use your own provider there. Episerver notifications always use a channel name, but replacing their formatter or provider isn't supported. You can probably hijack it somehow but I can't say it'd work 100%.
Cool thanks for input. A feature request then maybe... :-)
I have a custom INotificationProvider. It never triggers when a notification is sent.
I have the class implemented at the most basic level I can:
When an action occurs that should throw a notification, I can hit a breakpoint multiple times for ProviderName, so I know the system is aware that my provider exists. These calls are coming in from EPiServer.Notification.Internal.NotificationUserRepositoryImpl.GetUserPreferencesFromProviders.
However, SendAsync never executes.
I suspect it has something to do with the ChannelName and TypeName on the NotificationMessage, but I can't find any documentation to tell me what those should be. There doesn't seem to be a "mapping" between types/channels and specific providers.
How does a provider declare what channels or types it wants to handle? Also, since my provider seems to be called from a method called "GetUserPreferencesFromProviders," I'm wondering where these "user preferences" are and how they should be set.