PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync永远挂起应用程序

时间:2016-08-20 16:02:54

标签: windows azure push-notification windows-store-apps uwp

我已经通过了很多教程来使下面的方法工作,但是当它被执行时,应用程序会永远挂起,因为该方法永远不会完成。

PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync

该方法不会抛出任何异常,我也无法调试原因,我不确定我做错了什么,所以请纠正我的代码和应用程​​序功能。感谢。

通知初始化方法:

private async Task InitNotificationsAsync()
{
    try
    {
        Constants.NotificationChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
        Constants.NotifyHub = new NotificationHub("hub name", "access key");
        Constants.NotificationHubRegistration = await Constants.NotifyHub.RegisterNativeAsync(Constants.NotificationChannel.Uri);
        if (!(Constants.NotificationHubRegistration != null) || !(Constants.NotificationHubRegistration.RegistrationId != null)) await new MessageDialog("Microsoft Azure Push Notification Services are unavailable!", "Problem!?").ShowAsync();
    } catch (Exception e)
    {
        await new MessageDialog("Microsoft Azure Push Notification Services are unavailable!\n\n" + e.Message, "Problem!?").ShowAsync();
    }
}

应用程序功能:

  • 互联网(客户端和服务器)
  • 互联网(客户)
  • 位置
  • 用户帐户信息

0 个答案:

没有答案