【问题标题】:Unprocessable entity while subscriptions in quickblox在 quickblox 中订阅时无法处理的实体
【发布时间】:2016-05-21 23:53:00
【问题描述】:

我正在尝试订阅推送通知。我正在使用此代码,但显示以下错误。告诉我如何解决这个问题

NSString *deviceIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

//  New way, only for updated backends
//
QBMSubscription *subscription = [QBMSubscription subscription];
subscription.notificationChannel = QBMNotificationChannelAPNS;
subscription.deviceUDID = deviceIdentifier;
subscription.deviceToken = deviceToken;

[QBRequest createSubscription:subscription successBlock:^(QBResponse *response, NSArray *objects) {

    NSLog(@"Successfully!");

} errorBlock:^(QBResponse *response) {

}];

错误是:

"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 45;
"Content-Type" = "application/json; charset=utf-8";
Date = "Thu, 11 Feb 2016 09:04:28 GMT";
"QB-Token-ExpirationDate" = "2016-02-11 11:04:28 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.6.2";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = abeab57301c1210afb8d01a6f23d7f47;
"X-Runtime" = "0.119512";
"X-UA-Compatible" = "IE=Edge,chrome=1";

【问题讨论】:

  • 在错误块中打印 [response.error 原因],您将看到请求失败的确切原因。

标签: ios quickblox quickblox-android


【解决方案1】:

我有类似的代码,没有问题。
delegate.deviceToken 检查不为空。

QBMSubscription* qbm = [QBMSubscription subscription];
qbm.deviceUDID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
qbm.deviceToken = delegate.deviceToken;
qbm.notificationChannel = QBMNotificationChannelAPNS;

[QBRequest createSubscription:qbm successBlock:^(QBResponse * _Nonnull response, NSArray<QBMSubscription *> * _Nullable objects) {
     NSLog(@"createSubscription.success");
} errorBlock:^(QBResponse * _Nonnull response) {
     NSLog(@"createSubscription.error=%@", response.error.description);
}];

【讨论】:

    猜你喜欢
    • 2015-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-07
    相关资源
    最近更新 更多