How to create a Service Provider for NETnotifier

Now that you’ve installed NETnotifier and the WinForms client, you’re probably wondering… “Well? Is something supposed to happen?”. Not if you haven’t subscribed to any service. And even in that case, the said service should provide you with some notifications.

What is a service provider anyways?

A service provider (just Service in NETnotifier terminology) is any website, blog tool, application that is enabled to send notifications to NETnotifier. As of now, there is only one service, Dumpshock Forums, and that is a web forum based on Jive that deals with the Shadowrun role-playing game. I know, not exactly a wide mass appeal, but that’s the only service I had control upon during development.

It would be very nice – and useful – if other services would start popping up thus increasing the network effect of NETnotifier.

How do I enable my website/blog/etc to communicate with NETnotifier?

NETnotifier has a web service interface to let you register and send notifications. This means that your application doesn’t have to be written in C# or anything like that. In fact, my testbed service is a Java based forum, so interoperability was top of the list in my features list.

Step 1: Register your service

The first thing to do is register your service with NETnotifier. This will make your service appear in the service list and will ensure some kind of verification that’s actually you sending those notifications. In my C# example, the method call syntax is:

 NETnotifier.service serv = new NETnotifier.service(); String GUID = serv.RegisterService("MYSERVICE", "mypassword"); 

If GUID is not empty, it will contain a unique identifier that the service will have to resend to NETnotifier in all subsequent metod calls.

The service registration is persisted in the NETnotifier database for stability purposes (this means that I can shut down/restart my server and your service doesn’t have to register again)

In order to get your service code and password, at this point in time you just have to contact me. In the future I will make some kind of interface so you don’t have to actually talk with a human being, but everything is handled by an impassionate web robot.

Step 2: Send a notification

Sending a notification is pretty easy, again my C# sample syntax is:

 bool i = serv.SendNotification(GUID, "1", "1033", Guid.NewGuid().ToString(), "http://my.service.com/news.aspx?id=5", "Potato peeling tools breakthrough!", "NEWS", "Potato Peelers News"); 

The method returns a boolean, true if everything went peachy, false if something went wrong. Yes, I’ll write a better error handling routine soon.

The parameters used in SendNotification are:

serviceToken – the GUID returned by RegisterServer

version – version of the communication protocol (use “1”)

lang – language code (use “1033” for english-us, it’s the only code recognized now)

msgGUID – a unique identifier for your message. It doesn’t really have to be unique, but it will make life easier in logging and debugging for a future release

action – the URL to display when the user clicks on the alert

text – the text of the alert (limit this to 100 characters, for display on mobile devices)

channel – the service can send notifications on different channels. For example, a channel could be the URL for a web forum thread or a particular section of your website. If you don’t plan on using different channels, just put DEFAULT in this parameter

sitename – The name of your site, please keep it short 🙂

Step 3: Profit!

Well, actually, there’s no step 3 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *