Windows-8.1

In app toast notifcations using Toastinet in Windows Phone 8

Toastinet is a simple control that imitate a toast notification in Windows Phone. Developers would know that toast notifications don’t show up when the app is open. So you can imitate a toast using Toastinet. These days many apps like Facebook Messenger, Whatsapp, Twitter use in app toasts. It is available for download on Nuget and quite simple to implement. I am going to try it for the first time. I am also going to blog about it as I implement it in a sample application.

It is available at codeplex. Check it out for source code, documentations and discussions.

https://toastinet.codeplex.com/

Step 1. Create a new Windows Phone 8 app `Toastinet Test`

First things first, let us create a new Windows Phone 8 app and name it Toastinet Test

 

Step 2. Go to Nuget Package manager and install Toastinet

Search for Toastinet in Nuget Package manager and add it to your project. Here’s an article explaining how you could integrate a toolkit or third party SDK using with your Windows Phone app using Nuget Package Manager.

 

Step 3. Add a reference to the assembly for Toastinet

Add an assembly reference for using Toastinet in your XAML

xmlns:toastinet=”clr-namespace:Toastinet;assembly=Toastinet”

Step 3. Add the code below to add toasts in your page

Just below the Layout root add the code for toastinet. We also add a button to trigger toast notification in our app. There are lots customizations to personalize the toast notification. First we try the basic toast. This is how the main page of the app looks. The code for toasts is also embedded below.

 

 

  Step 4. Add the click event handler for Trigger toast button This will simply display a toast notification when clicked. You just have to set the Message property of the Toast control to see the toast appear. this.Toast2.Message = “This is a basic toast”;   The code behind looks something like this.  

That’s all we need to do. Let run it in the emulator and see the results. It doesn’t look very pretty but at-least it works.

I tried a few customizations and the results were quite good. I have managed to get in app toasts similar to standard toasts. Here’s the code that would be needed. I even hid the system tray to make it look even better. There are various animations to choose from to get different toast effects.

 

 

Toastinet also supports various event handlers. I tried the tap event handler to navigate to a different page. It worked smoothly and you need to add an event trigger just as you would do with any other control. For the record, it took me just 48 minutes to implement and simultaneously blog about it.

Here’s the full source code of the tiny project

Download full source code Toastinet-Test.zip

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close