У меня возникла проблема с отображением уведомления Toast, следуя руководству.
Вот сценарий сервера мобильной службы Azure:
function insert(item, user, request) {
request.execute({
success: function () {
// Write to the response and then send the notification in the background
request.respond();
push.mpns.sendToast(item.channel, {
text1:"Sent from cloud!"
}, {
success: function (pushResponse) {
console.log("Sent push:", pushResponse);
}
});
}
});
И это код, который я поместил в App.xaml.cs:
//push notification
public static HttpNotificationChannel CurrentChannel { get; private set; }
private void AcquirePushChannel()
{
CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");
if (CurrentChannel == null)
{
CurrentChannel = new HttpNotificationChannel("MyPushChannel");
CurrentChannel.Open();
//CurrentChannel.BindToShellTile();
CurrentChannel.BindToShellToast();
}
}
private void Application_Launching(object sender, LaunchingEventArgs e)
{
AcquirePushChannel();
}
Но тост по-прежнему не выходит (флиптайл работает хорошо).
Любая модификация, необходимая для работы тоста?
РЕДАКТИРОВАТЬ: ошибка при открытии канала:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=Open failed because the channel was already open. You can find an open channel by calling the Find method.
Source=Microsoft.Phone
StackTrace:
at Microsoft.Phone.Notification.SafeNativeMethods.ThrowExceptionFromHResult(Int32 hr, Exception defaultException, NotificationType type)
at Microsoft.Phone.Notification.HttpNotificationChannel.Open()
at UtemFtmkDB.App.AcquirePushChannel()
at UtemFtmkDB.App.Application_Launching(Object sender, LaunchingEventArgs e)
at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()
at Microsoft.Phone.TaskModel.Interop.ITask.Launching.Invoke()
at Microsoft.Phone.TaskModel.Interop.Task.FireOnLaunching()
InnerException: