我打电话给let push = IMFPushClient.sharedInstance()
logger?.logInfoWithMessages("subscribe to tags: \(tagsArray)")
push.subscribeToTags([tagsArray]) { (response: IMFResponse!, error: NSError!) -> Void in
订阅了一个标签,但是从堆栈跟踪中获得了400个。
2016-01-22 16:48:10.648 gschat-swift[44084:5194666] [INFO] [BlueList] subscribe to tags: ["Test"]
2016-01-22 16:48:10.648 gschat-swift[44084:5194666] [INFO] [IMFPushClient] -[IMFPushClient subscribeToTags:completionHandler:] in IMFPushClient.m:314 :: Entering: subscribeToTags.
2016-01-22 16:48:10.650 gschat-swift[44084:5194666] [DEBUG] [IMF] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:44 :: Request url is https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions
2016-01-22 16:48:10.653 gschat-swift[44084:5194666] [DEBUG] [IMF] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:194 :: Starting the request with URL https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions
2016-01-22 16:48:11.255 gschat-swift[44084:5194362] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:215 :: Request Failed
2016-01-22 16:48:11.256 gschat-swift[44084:5194362] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:216 :: Response Status Code : 400
2016-01-22 16:48:11.257 gschat-swift[44084:5194362] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:217 :: Response Error : Expected status code in (200-299), got 400
2016-01-22 16:48:11.259 gschat-swift[44084:5194362] [ERROR] [IMFPushClient] __51-[IMFPushClient subscribeToTags:completionHandler:]_block_invoke in IMFPushClient.m:350 :: Error while subscribing to tags - Error is: Error Domain=WLAFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 400" UserInfo={WLAFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x7f89b8d8dd10> { URL: https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions }, NSLocalizedRecoverySuggestion={"message":"Bad Request - Invalid JSON","code":"FPWSE0004E"}, NSErrorFailingURLKey=https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions, WLAFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x7f89b8eb7f00> { URL: https://chatbms.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions } { status code: 400, headers {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Fri, 22 Jan 2016 16:48:09 GMT";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "FAIL FAIL";
"X-Cf-Requestid" = "cf162009-bd95-46d2-46ca-3cad50a70153";
"X-Client-IP" = "80.111.218.187";
"X-Global-Transaction-ID" = 2240839783;
"X-Powered-By" = "Servlet/3.0";
} }, NSLocalizedDescription=Expected status code in (200-299), got 400}
2016-01-22 16:48:11.260 **gschat-swift[44084:5194362] [FATAL] [BlueList] error Error Domain=com.ibm.mobilefoundation.push Code=10 "Expected status code in (200-299), got 400" UserInfo={WLAFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x7f89b8d8dd10> { URL: https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions }, NSLocalizedRecoverySuggestion={"message":"Bad Request - Invalid JSON","code":"FPWSE0004E"}, NSErrorFailingURLKey=https://ChatBMS.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions, WLAFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x7f89b8eb7f00> { URL: https://chatbms.mybluemix.net/imfpush/v1/apps/2b7d11a9-57bf-47e6-8a4c-8aabf044ac8a/subscriptions } { status code: 400, headers {
Connection = "Keep-Alive";
"Content-Type" = "application/json";
Date = "Fri, 22 Jan 2016 16:48:09 GMT";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "FAIL FAIL";
"X-Cf-Requestid" = "cf162009-bd95-46d2-46ca-3cad50a70153";
"X-Client-IP" = "80.111.218.187";
"X-Global-Transaction-ID" = 2240839783;
"X-Powered-By" = "Servlet/3.0";
} }, NSLocalizedDescription=Expected status code in (200-299), got 400} in subscribe to tags:["Test"]**
答案 0 :(得分:0)
我可以在错误中看到您在尝试订阅时提供无效的JSON。如果您尝试订阅所有可用标记,则首先需要获取可用标记,然后在订阅时使用这些标记。例如:
斯威夫特:push.retrieveAvailableTagsWithCompletionHandler
{
(response: IMFResponse!, error: NSError!) -> Void in
let tags = response.availableTags()
if (tags.count > 0)
{
//lets subcribe to all tags for demo purposes
push.subscribeToTags(tags, completionHandler:
{ (response: IMFResponse!, error: NSError!) -> Void in
})
}
}
以下是提供进一步见解的文档: