0

真的让我感到惊讶的是,像微软这样的公司不会给你可读的错误信息。我只是试图将设备注册到我们天蓝色的通知中心。Xamarin通知中心注册错误

if (App.DeviceInfo.DeviceManufacturer == "Apple") 
{ 
    if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) 
    { 
     var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
       UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, 
       new NSSet()); 

     UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); 
     UIApplication.SharedApplication.RegisterForRemoteNotifications(); 
    } 
    else 
    { 
     UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; 
     UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); 
    } 
} 

注册回调

public override void RegisteredForRemoteNotifications(UIApplication app, NSData deviceToken) 
{ 
    //// Connection string from your azure dashboard 
    var cs = WindowsAzure.Messaging.SBConnectionString.CreateListenAccess(
     new NSUrl(AzureServiceBusConnectionString), 
     AzureHubName); 

    // Register our info with Azure 
    var hub = new WindowsAzure.Messaging.SBNotificationHub(cs, AzureHubName); 
    hub.RegisterNativeAsync(deviceToken, null, err => 
    { 
     if (err != null) 
     { 
      Console.WriteLine("Error: " + err.Description); 
      Console.WriteLine(err.DebugDescription); 
     } 
     else 
      Console.WriteLine("Success"); 
    }); 
} 

这里的错误讯息,我回去

Error: Error Domain=WindowsAzureMessaging Code=401 "URLRequest failed for { URL: https://****.servicebus.windows.net/****/Registrations/?$filter=deviceToken+eq+'****'&api-version=2013-04 } with status code: unauthorized" UserInfo={NSLocalizedDescription=URLRequest failed for { URL: https://****.servicebus.windows.net/newsernotificationhub/Registrations/?$filter=deviceToken+eq+'****'&api-version=2013-04 } with status code: unauthorized}

所以,唯一的消息我得到的回复是unauthorized,只是想知道一些原因,为什么它会当我使用azure中给定的端点url时,请返回unauthorized,并返回通知中心名称。

+0

你可以通过[诊断指南](https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-fixer)并更新问题如果有东西仍然不起作用?首先,了解问题出在服务端还是客户端,这一点很重要。目前听起来更像客户端。提供了可能错误的中心证书。 –

+0

那么没有客户端。我正在Xamarin应用程序中注册设备服务器端。尝试与天蓝色的通知中心通话以注册设备。我不确定该页面如何帮助,我认为这可能是在处理实际发送通知?可能是错误的,但这就是我所理解的。 – jdmdevdotnet

+0

'“在最初的测试/分期阶段,可能会发生未能发送通知的情况,这可能表示配置问题,或者可能发生在生产中,可能会导致全部或部分通知丢失,从而指示出一些更深的应用程序或消息传递模式问题。” '这涉及诊断没有交付的通知。与我的问题无关。 – jdmdevdotnet

回答

0

我的问题是一些我看到的文档,它告诉你做的这个

//// Connection string from your azure dashboard 
var cs = WindowsAzure.Messaging.SBConnectionString.CreateListenAccess(
    new NSUrl(AzureServiceBusConnectionString), 
    AzureHubName); 

// Register our info with Azure 
var hub = new WindowsAzure.Messaging.SBNotificationHub(cs, AzureHubName); 

如果真的那么有必要为这个

var hub = new WindowsAzure.Messaging.SBNotificationHub(AzureServiceBusConnectionString, AzureHubName); 

因此,当你实例化一个新SBNotificationHub ,您只需提供连接字符串和集线器名称。没有做CreateListenAccess

相关问题