Integration of Windows LIVE SDK Connect & Push Notifications in Windows 8 Metro Style Apps using Windows Live SDK


Windows Live SDK is quite essential for integrating Windows LIVE CONNECT with Metro Style Apps as well as with LIVE Push Notifications. In this article we will see how to integrate Windows LIVE CONNECT & Push Notification services from Windows Azure (Cloud) to Windows 8 Metro Style Apps.  First of all , you need to Download & install Windows Live SDK from

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=28195

Now, Install the Live SDK & Check out the Extension on VS 11 Developer Preview in Add Reference section.

  • Now create a new Metro Style project in VS 11 Developer Preview .

  • Now write some simple code in MainPage.xaml:

<Grid x:Name=”LayoutRoot” Background=”#FF0C0C0C”>

<Grid.ColumnDefinitions>

<ColumnDefinition Width=”251*” />

<ColumnDefinition Width=”1116*” />

</Grid.ColumnDefinitions>

<StackPanel Grid.ColumnSpan=”2″>

<live:SignInButton Name=”btnLogIn” Scopes=”wl.signin wl.basic” />

<TextBlock Name=”tbName” Width=”600″ Height=”150″ FontSize=”32″ TextWrapping=”Wrap” />

<TextBlock Name=”tbGender” Width=”600″ Height=”150″ FontSize=”32″ TextWrapping=”Wrap” />

<TextBlock Name=”tbLiveProfile” Width=”600″ Height=”150″ FontSize=”32″ TextWrapping=”Wrap” />

<TextBlock Name=”tbError” Text=”Error Message” Width=”600″ Height=”150″ FontSize=”32″ />

</StackPanel>

</Grid>

  • Same way modify MainPage.xaml.cs :

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using Windows.Foundation;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Data;

using Microsoft.Live;

using  Microsoft.Live.Controls;

namespace LiveSDKDemo

{

partial class MainPage

{

private LiveConnectClient liveClient;

private LiveConnectSession session;

 public MainPage()

{

InitializeComponent();

      this.btnLogIn.SessionChanged += btnLogIn_OnSessionChanged;

}

private void btnLogIn_OnSessionChanged(object sender, LiveConnectSessionChangedEventArgs e)

{

if(e.Session != null && e.Status == LiveConnectSessionStatus.Connected)

{

this.liveClient = newLiveConnectClient(e.Session);

session = e.Session;

this.liveClient.GetCompleted += OnGetCompleted;

this.liveClient.GetAsync(“me”,null);

}

   else

{

this.liveClient = null;

}

}

private  void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)

{

if (e.Error == null)

{

dynamic result = e.Result;

his.tbName.Text = “Hello,” + result.first_name + ” “ + result.last_name;

this.tbGender.Text = “You are “ + result.gender + “that lives in “ + result.locale + “.”;

this.tbLiveProfile.Text = “Your Live Profile can be found:” + result.link;

}

else

{

this.tbError.Text = e.Error.ToString();

}

}

}

}

  • Now , after pressing F5 , you will be stuck with the following message:

  • You need to login to https:manage.dev.live.com  with your Windows Live ID & add the Metro Style Apps Package Name & Publisher Name in Windows Live Connect Portal to integrate LIVE SDK CONNECT & Push notifications with your Metro Style Apps.

  • Accept the  Terms & Condition to get the Live Application Package Name ID & paste it in your package.appxmanifest file.

  • Now Press F5 & Test it in Windows 8 Simulator & check out the following output.

  • Click on Yes & you will be signed in with Windows LIVE SDK Connect & enable to receive Push notifications in your Metro style apps.

Advertisements
%d bloggers like this: