像微软这样的公司并没有给你提供可读的错误信息,这真让我感到惊讶。我只是试图将设备注册到我们天蓝色的通知中心。
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");
});
}
这是我收到的错误消息
错误:错误域= WindowsAzureMessaging代码= 401" URLRequest失败 对于{URL: ?HTTPS://****.servicebus.windows.net/****/Registrations/ $过滤= deviceToken + EQ +' ****'&安培; API版本= 2013- 04 }状态码:未授权" UserInfo = {NSLocalizedDescription = URLRequest失败 {URL: ?HTTPS://****.servicebus.windows.net/newsernotificationhub/Registrations/ $过滤= deviceToken + EQ +' ****'&安培; API版本= 2013-04 }状态代码:unauthorized}
所以我收到的唯一消息是unauthorized
,只是想知道当我使用azure中给出的端点网址时,它会以unauthorized
返回的原因是什么?通知中心名称。
答案 0 :(得分: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