我正在尝试在我的Windows Phone 7.1中发送推送通知,这会引发错误:
PushSharp.WindowsPhone.WindowsPhoneNotificationSendFailureException
以下是服务器端编写的中间件代码:
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;
// WINDOWS PHONE NOTIFICATIONS
push.RegisterWindowsPhoneService();
push.QueueNotification(new WindowsPhoneToastNotification()
.ForEndpointUri(new Uri(url))
.ForOSVersion(WindowsPhoneDeviceOSVersion.Seven)
.WithBatchingInterval(BatchingInterval.Immediate)
// .WithNavigatePath("/MainPage.xaml")
.WithText1("Notification")
.WithText2("This is a push notification"));
push.StopAllServices(waitForQueuesToFinish: true);
Push sharp handler方法是:
//this even raised when a notification is successfully sent
static void NotificationSent(object sender, INotification notification)
{
Debug.WriteLine("Sent: " + sender + " -> " + notification);
}
//this is raised when a notification is failed due to some reason
static void NotificationFailed(object sender, INotification notification, Exception notificationFailureException)
{
Debug.WriteLine("Failure: " + sender + " -> " + notificationFailureException.Message + " -> " + notification);
}
从前端使用VS 2010 for windows phone framework我发送的URL是自动生成的:
Notification channel URI:http://db3.notify.live.net/throttledthirdparty/01.00/AQE9Hz23hR07RYiaH7O3SeEkAgAAAAADAQAAAAQUZm52OjIzOEQ2NDJDRkI5MEVHHSNLL8wMQ
但遗憾的是,我收到以下例外情况:
Failure: PushSharp.WindowsPhone.WindowsPhonePushService -> Exception of type 'PushSharp.WindowsPhone.WindowsPhoneNotificationSendFailureException' was thrown. -> <wp:Notification xmlns:wp="WPNotification">
帮帮我。提前谢谢。
答案 0 :(得分:0)
当我尝试使用设备
时,相同的代码有效不是模拟器。可能是由于虚拟凭据而发生错误。