If you haven’t read part one in this series, please do so before continuing.
In part one, we implemented the SendGrid Event Webhook listener using C# ASP.NET hosted on Microsoft Azure.
In this post (part two), we will create a Windows Phone 8.1 app that displays email tracking data via the SendGrid Web API.
In part three of this series, we will send push notifications from our SendGrid Event Webhook listener when certain events, such as a bounce, occur and display the details within the app.
The code for this post (source) was developed within VMWare Fusion 6 on Mac OS X Mavericks, running Windows 8.1 in Visual Studio Express 2013 for Windows. This code was also tested on a Microsoft Surface Pro running Windows 8.1.
BIG thanks to Alex Reed, our SendGrid Ambassador serving the UK, for creating the first version of this code.
The code is based on the Hub App (Windows Phone) template. I suggest you watch parts 15 to 17 of Bob Tubor’s “Windows Phone 8.1 Development for Absolute Beginners” video series for an understanding of how the application template works. Start at part 1 if you are completely new to the Windows Phone 8 development platform.
Clone the repo and follow the set-up instructions in the README, then run the app in Visual Studio. You should see a screen similar to the leading intro image.
Understanding the Code
Accessing SendGrid: SendGridApi.cs
This class communicates with the SendGrid Web API. Specifically, we are accessing the stats endpoint through the GetStats function.
Defining the Data Model: EmailStats.cs
This class defines the data we will receive from the stats endpoint. Note that we have accounted for all of the data points from the stats endpoint in this model, but we do not display them all in the app’s interface.
Creating the Display: SendGridStats.WindowsPhone/Pages
This folder contains the templates (.xaml) and code (.cs) that displays our data. The main page of the app, is defined in HUbPage.xaml and HubPage.xaml.cs.
If you would like a solid foundational understanding of XAML, see the Microsoft Dev Center.
Next: Part 3