Windows push notification service using Pushsharp giving Notification Failure -
var push = new pushbroker(); push.onnotificationsent += notificationsent; push.onchannelexception += channelexception; push.onserviceexception += serviceexception; push.onnotificationfailed += notificationfailed; push.ondevicesubscriptionexpired += devicesubscriptionexpired; push.ondevicesubscriptionchanged += devicesubscriptionchanged; push.onchannelcreated += channelcreated; push.onchanneldestroyed += channeldestroyed; push.registerwindowsphoneservice(); push.queuenotification(new windowsphonetoastnotification() .forendpointuri(new uri(uri)) .forosversion(windowsphonedeviceosversion.eight) .withbatchinginterval(batchinginterval.immediate) .withnavigatepath("/landingview.xaml") .withtext1("pushsharp") .withtext2("this toast")); push.stopallservices();
i using pushsharp nuget package push notifications , while passing uri c# backend code windows, getting notification failure exception.
i using latest version of pushsharp (version 3.0) in project of mine send toast notifications windows phone devices , working fine me. notice code have above using older version of pushsharp package, there new 3.0 version available nuget.
you use latest package send toast notification windows phone devices. latest version of pushsharp uses wns opposed old mpns.
if go nuget link supplied above , download solution can see examples on how implement push notifcations windows phone using wns. under pushsharp.test
project (look wnsrealtest.cs
file).
below example of how can send toast notification windows phone device:
var config = new wnsconfiguration( "your-wnspackagenameproperty", "your-wnspackagesid", "your-wnsclientsecret" ); var broker = new wnsservicebroker(config); broker.onnotificationfailed += (notification, exception) => { //you here }; broker.onnotificationsucceeded += (notification) => { //you here }; broker.start(); broker.queuenotification(new wnstoastnotification { channeluri = "your device channel uri", payload = xelement.parse(string.format(@" <toast> <visual> <binding template=""toasttext02""> <text id=""1"">{0}</text> <text id=""2"">{1}</text> </binding> </visual> </toast> ","your header","your toast message")) }); broker.stop();
as may notice above wnsconfiguration
constructor requires package name, package sid, , client secrete. these values app must registered store dashboard. provide credentials app cloud service use in authenticating wns. can check steps 1-3 on following msdn page details on how done. (note in link above states have edit appmanifest.xml file identity of app, did not step, make sure have windows phone app setup correctly receive toast notification, blog post that.
hope helps.
Comments
Post a Comment