Did you know you can easily create your own Windows Phone Push Notifications using the Notify My Windows Phone app?
NMWP is a platform that helps you push information to virtually any Windows Phone 7 (and 8) device you own.
What do you need to get started?
- Windows Phone 7 or 8
- The NMWP app from the Microsoft Store ($1.99)
- NMWP Api key
- PowerShell script to call the Web API
First we need to install the The NMWP app from the Microsoft Store on our Windows Phone. Open the Windows Store app on your Windows Phone and install the app.
Next we need to Sign up at http://www.nmwp7.com/user/register and create a username and password.
After registering you need to enter your username and password at the Notify my Windows Phone app on your Windows Phone.
And at last we need to request an API key on the http://www.nmwp7.com/user/apikeys website.
After requesting the API key you can test the key using the Send testmessage button.
Hopefully now everything is working as expected.
Testing Notify My Windows Phone from PowerShell
If you look at the API help it’s pretty simple to call the API. With PowerShell v3 you can use the Invoke-WebRequest cmdlet to call the Web API.
A simple PowerShell script to call the Web API can look something like this:
#Requires -Version 3####################################################################################################################### # Using the Notify my Windows Phone API using PowerShell # Author: Stefan Stranger # Disclamer: This program source code is provided "AS IS" without warranty representation or condition of any kind # either express or implied, including but not limited to conditions or other terms of merchantability and/or # fitness for a particular purpose. The user assumes the entire risk as to the accuracy and the use of this # program code. # Date: 01-05-2012 # Name: NotifyMyWindowPhone.ps1 # v0.01 - 01-05-2012 - Stefan Stranger - sstranger's initial release ######################################################################################################################### Enter your own API Key from http://www.nmwp7.com/user/apikeys$apikey="[enter here your api key]"# Enter the name of the application the notification originates from. $application="WindowsPowerShell"# Enter The event that occured. Depending on your application, this might be a summary, subject or a brief explanation.$event="Push Message sent from PowerShell"# The full body of the notification. $description="This message was sent as a test"# An optional value representing the priority of the notification.$priority="-2"# Specifies the responsetype you want. You can currently choose between JSON or XML (default)$type="json"$uri="http://notifymywindowsphone.com/publicapi/notify?event=$event&priority=$priority&application=$application&description=$description&apikey=$apikey&type=$type" Invoke-WebRequest -Uri $uri
If you run above PowerShell script you will see the following result returned in your console.
Now you would see the push notification on your Windows Phone.
In my next blog post I’ll explain how you can use above to create Windows Phone Push Notifications for your OpsMgr Alerts using the Notification Command Channel.
Have fun!