【发布时间】:2017-03-04 19:24:40
【问题描述】:
一切看起来都配置正确。我已经看过很多次了。这是我得到的:
Service Bus Explorer 在我连接时返回:
<23:36:44> The application is now connected to the
sb://localesnotify.servicebus.windows.net/ service bus namespace.
<23:36:44> MessagingFactory successfully created
<23:37:24> Exception: The remote server returned an error: (500) Internal Server Error. TrackingId:20b6388b-2599-428a-a7b8-2c81eba6b309,TimeStamp:3/4/2017 4:37:24 AM
<23:37:24> InnerException: The remote server returned an error: (500) Internal Server Error
在所有情况下,当我在我的设备上进行测试时,RegisteredForRemoteNotifications 都会成功返回。
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath);
Hub.UnregisterAllAsync(deviceToken, (error) => {
if (error != null)
{
Console.WriteLine("Error calling Unregister: {0}", error.ToString());
return;
}
NSSet tags = null; // create tags if you want
Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
if (errorCallback != null)
Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
});
});
var alert = new UIAlertView("Remote Notifications", "Registered!", null, "OK", null);
alert.Show();
}
我的证书和配置文件似乎在 Azure 和 Xamarin 上都正确配置了。
我尝试了不同的连接字符串和通知中心网址。不确定要使用哪些。但我想尽了一切办法。
// Azure app-specific connection string and hub path
public const string ConnectionString = "Endpoint=sb://localesnotify.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=1QMNeVitGRUxoZvkgnx8klpJGsJ5LfX/057jL+CD2VE=";
public const string NotificationHubPath = "sb://localesnotify.servicebus.windows.net";
当我从 Azure 测试发送时,它显示已成功完成,但我从未收到消息。
我的 ReceivedRemoteNotification 没有触发。所以我猜我的客户端没有正确连接。同样在经典门户中,它说没有找到所选平台的注册。
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
ProcessNotification(userInfo, false);
}
有什么想法吗?
【问题讨论】:
-
将
NoficationHubPath更改为您在 Azure 中命名的集线器名称。 -
我有一些选择。这来自经典门户:localesnotify.servicebus.windows.net/localesnotify。这是来自新门户:服务端点LocalesNotify.servicebus.windows.net:443。这是应用服务locales.azurewebsites.net
-
这不是一个 url 只是一个名字。在 azure 中,这将是对象的名称。图标通常为橙色。
-
ObjecInAzure:dropbox.com/s/1oojidpi3ejzoaj/azure-hub.png?dl=0 NameFromProperties:dropbox.com/s/22ygq2py1u5bg0s/azure-hub-name.png?dl=0 抱歉,我使用的是外部链接,但 cmets 不支持图像。
-
然后就是这个.. LocalesNotify - 现在试试..
标签: azure push-notification xamarin.ios apple-push-notifications