Whenever I am trying to create push notification in windows phone 7 and windows phone 8, my code is working fine but whenever I tried to build same code on windows phone 8.1, it's showing 'System.NullReferenceException' Occur when generate Chanal Uri In Windows Phone 8.1.
Code is given below :
String channelUri="XYZ";
HttpNotificationChannel myPushChannel = HttpNotificationChannel.Find(channelUri);
if (null == myPushChannel)
{
myPushChannel = new HttpNotificationChannel(channelUri);
myPushChannel.Open();
myPushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(myPushChannel_ShellToastNotificationReceived);
myPushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(myPushChannel_ChannelUriUpdated);
myPushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(myPushChannel_ErrorOccurred);
myPushChannel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(myPushChannel_HttpNotificationReceived);
myPushChannel.BindToShellTile();
myPushChannel.BindToShellToast();
uri = myPushChannel.ChannelUri;
}
else
{
if (myPushChannel != null)
{
myPushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(myPushChannel_ShellToastNotificationReceived);
myPushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(myPushChannel_ChannelUriUpdated);
myPushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(myPushChannel_ErrorOccurred);
myPushChannel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(myPushChannel_HttpNotificationReceived);
uri = myPushChannel.ChannelUri;
if (!myPushChannel.IsShellToastBound)
myPushChannel.BindToShellToast();
if (!myPushChannel.IsShellTileBound)
myPushChannel.BindToShellTile();
}
}
}
Everything is working fine in windows phone 7/8 but not working on windows phone 8.1.