Unprocessable entity while subscriptions in quickblox

272 Views Asked by At

I'm trying to subscription for push notification. I'm using this code but that show below error. Tell me how to fix this issue

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) {

}];

Error is:

"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";
1

There are 1 best solutions below

0
On

I have similar code and don't have a problem.
delegate.deviceToken is checked not-null.

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);
}];