【问题标题】:URLRequest failed on Notification Hub iOS通知中心 iOS 上的 URLRequest 失败
【发布时间】:2017-11-11 04:23:18
【问题描述】:

Azure 通知中心未注册到服务器。我没有更改将设备注册到服务器的代码中的任何内容。以前它工作得很好,但现在不行。

运行此代码时遇到此问题:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBFULLACCESS notificationHubPath:HUBNAME];
    [hub unregisterAllWithDeviceToken:deviceToken completion:^(NSError* error){
        dispatch_async(dispatch_get_main_queue(), ^{
            [hub registerNativeWithDeviceToken:deviceToken tags:tags completion:^(NSError* error) {
                if (error != nil) {
                    NSLog(@"Error registering for notifications: %@", error);
                } else {
                    NSLog(@"Registerd for notification");
                }
            }];
        });
    }];
});

这是错误:

Error Domain=WindowsAzureMessaging Code=400 "对于 { URL: https://.servicebus.windows.net//Registrations/2044525541292942848-4457854038111768645-1?api-version=2013-04 } 的 URLRequest 失败,状态码:bad请求” UserInfo={NSLocalizedDescription=URLRequest 失败 { URL: https://.servicebus.windows.net//Registrations/2044525541292942848-4457854038111768645-1?api-version=2013-04 } 状态码:错误请求}

我检查了所有证书和配置文件,一切都很好。

【问题讨论】:

  • 你检查request headers了吗?你试过api-version=2015-01吗?你试过registrations小写吗?

标签: ios push-notification azure-notificationhub


【解决方案1】:

正如Create Registration 所说的大约 400 个响应代码:

请求正文无效。由于请求格式错误,无法创建注册。

据我了解,您可以利用fiddlerCapture Traffic from iOS Device 获取详细的错误消息,这是我的测试,您可以参考:

此外,我假设您需要检查标签的格式。正如Routing and Tag Expressions 所说的标签

标签可以是任何字符串,最多 120 个字符,包含字母数字和以下非字母数字字符:“_”、“@”、“#”、“.”、“:”、“-”。

【讨论】:

    猜你喜欢
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-28
    • 2016-11-02
    • 1970-01-01
    • 1970-01-01
    • 2019-09-24
    相关资源
    最近更新 更多