我已经通过了很多教程来使下面的方法工作,但是当它被执行时,应用程序会永远挂起,因为该方法永远不会完成。
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();
}
}
应用程序功能: