(Code Snippet Using Push Notifications MainPage.xaml.cs Subscribe – – – toNotifications call) C# SubscribeToNotifications(); The locations to add this code snippet are the following: In the ConnectToMSPN function, in the try between and “SubscribeToService();” “Dispatcher.BeginInvoke();” C# if (null != httpChannel) { Trace("Channel Exists - no need to create a new one"); SubscribeToChannelEvents(); the URI with 3rd party web service"); SubscribeToService(); to the channel to Tile and Toast notifications"); SubscribeToNotifications(); Dispatcher.BeginInvoke(() => UpdateStatus("Channel recovered")); } In the httpChannel_ChannelUriUpdated function, between and “SubscribeToService();” “Dispatcher.BeginInvoke(…);” C# void httpChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e) { Trace("Channel opened. Got Uri:\n" + httpChannel.ChannelUri.ToString()); Dispatcher.BeginInvoke(() => SaveChannelInfo()); Trace("Subscribing to channel events"); SubscribeToService(); SubscribeToNotifications(); Dispatcher.BeginInvoke(() => UpdateStatus("Channel created successfully")); }
(Code Snippet – Using Push Notifications – MainPage.xaml.cs – Subscribe toNotifications call) C# SubscribeToNotifications(); The locations to add this code snippet are the following: In the ConnectToMSPN function, in the try between “SubscribeToService();” and “Dispatcher.BeginInvoke();” C# if (null != httpChannel) { Trace("Channel Exists - no need to create a new one"); SubscribeToChannelEvents(); the URI with 3rd party web service"); SubscribeToService(); to the channel to Tile and Toast notifications"); SubscribeToNotifications(); Dispatcher.BeginInvoke(() => UpdateStatus("Channel recovered")); } In the httpChannel_ChannelUriUpdated function, between “SubscribeToService();” and “Dispatcher.BeginInvoke(…);” C# void httpChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e) { Trace("Channel opened. Got Uri:\n" + httpChannel.ChannelUri.ToString()); Dispatcher.BeginInvoke(() => SaveChannelInfo()); Trace("Subscribing to channel events"); SubscribeToService(); SubscribeToNotifications(); Dispatcher.BeginInvoke(() => UpdateStatus("Channel created successfully")); }
UsingPushNotifications.docx