My Custom Notification Provider Will Not Execute

Vote:
 

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:

[ServiceConfiguration(typeof(INotificationProvider))]
    public class MyNotificationProvider : INotificationProvider
    {
        public string ProviderName { get { return "MyProvider"; } }

        public NotificationFormat GetProviderFormat() { return new NotificationFormat { MaxLength = null, SupportsHtml = true }; }

        public Task SendAsync(IEnumerable messages, Action succeededAction, Action failedAction)
        {
            // Do stuff
        }
    }

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.

#182425
Sep 18, 2017 21:30
Vote:
 

Hey Deane,

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:

http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=182085&pageIndex=1

BR,

Marija

#182964
Oct 02, 2017 15:30
Vote:
 

Hey,

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. 

/Per

#184874
Nov 06, 2017 17:14
Vote:
 

Hi Deane,

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.csNotificationFormatter.cs, and NotificationInitialize.cs.

#185031
Nov 08, 2017 14:33
Vote:
 

Hey, 

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.

regards

Per

#185033
Nov 08, 2017 15:27
Vote:
 

Hi Per,

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%.

#185034
Nov 08, 2017 15:57
Vote:
 

Cool thanks for input. A feature request then maybe... :-)

#185035
Nov 08, 2017 16:02
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.