INotificationPlugin

This is the notification method plugin interface to implement when a new customer-defined notification method is wanted.

Methods

Name Description

Notify

Notify is called when Pointsharp ID or PSIDAdmin wants to notify a user either in one of the built-in authentication methods or when provisioning OATH or MTP tokens.

Parameters

Name Description

recipient (System.String)

The recipient address, for example the mobile number or the email address.

text (System.String)

The text to be notified.

Returns

True if successful, false otherwise.

Examples

The notification plugin enable us to create a customized notification method. Here is a sample implementation of the INotificationPlugin that writes the message to a file with the recipient as file name.

Test Notification Plugin
using Psid.API.Notification;
using System.IO;

namespace PointSharp.Api.Examples
{
    /// <summary>
    /// An example implementation of the Psid.API.Notification.INotificationPlugin
    /// </summary>
    public class TestNotification : INotificationPlugin
    {
        private string _notificationFolder;

        public TestNotification()
        {
            // The folder to write the messages into
            this._notificationFolder = @"C:\Program Files\PointSharp\PointSharp ID\notifications";
        }

        public string Description
        {
            get { return "My Test Notification"; }
        }

        public string Name
        {
            get { return "TestNotification"; }
        }

        public bool Notify(string text, string recipient)
        {
            var isNotified = false;

            try
            {
                // TODO: Handle more than one message to the same recipient

                // The full path to the file to write the message to
                var notificationTextFile = Path.Combine(
                    this._notificationFolder,
                    recipient + ".txt"
                    );

                // Write to file
                File.WriteAllText(notificationTextFile, text);
                isNotified = true;
            }
            catch
            {
                // TODO: Write exception to log...
            }

            return isNotified;
        }
    }
}