QuickBlox after some time Sender become receiver and receiver become Sender - ios

i am using QuickBlox Simple Chat for how to know how it was working.
In demo ex.2 user first is USER1 and Other is USER2.
After some time USER1 message display in table where the side of USER2 message and USER2 message is display in side of USER1 messages.
Get a response to the server like this
Request finished, response:
RestResponse:
------
<QBASIHTTPRequest: 0xa288c00>
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = Close;
"Content-Length" = 106;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Sat, 05 Oct 2013 05:54:05 GMT";
"QB-Token-ExpirationDate" = "2013-10-05 07:53:46 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = c70e07ac0a8571253773cde59c23676c;
"X-Runtime" = "0.223264";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>No one can receive the message</error>
</errors>
error:

Related

restkit ios: authentication start failing, if user provide wrong credential in first attempt and correct credential in subsquent attempts

When application is failed to login/authenticate successfully with restkit in first attempts due to wrong username or password, application never get success even with correct username and password, any help would be appreciated in this.
On login button i create the restkit instance and pass the information here is the code
func sendLoginRequest(userName:String,password:String){
let authenticate:String = String(format: "%#:%#", userName, password)
let plainData = (authenticate as NSString).dataUsingEncoding(NSUTF8StringEncoding)
let base64String = plainData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0))
print(base64String)
headers = ["Authorization" : String(format: "Basic %#", base64String)]
self.webInterface = DFWebInterface.shareWebInterface(DFModel.sharedInstance.bMockServer)
self.webInterface?.sendRequest(nil,request: LOGIN.rawValue, nil,headers: headers as! [NSObject : AnyObject])
}
then initialize my web interface class
-(id)init:(NSString*)strURL :(BOOL)mockServer{
if(nil!=(sDFWebInterface=[super init])){
NSURL *baseURL = [NSURL URLWithString:strURL];
DFAFHTTPClient* client=[[DFAFHTTPClient alloc] initWithBaseURL:baseURL];
sDFWebInterface->rkobjmanagerDF = [[RKObjectManager alloc] initWithHTTPClient:client];
[RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:#"text/plain"];
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
}
return sDFWebInterface;
}
After initializing i create mapping and send post request
Everything works fine if application send correct credential very first time
Here is the log for second time fail even application passing correct credential
2016-02-11 12:07:44.242 MyProject[7033:94063] I restkit.network:RKObjectRequestOperation.m:150 POST 'https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate'
2016-02-11 12:07:45.215 MyProject[7033:95645] E restkit.network:RKObjectRequestOperation.m:551 Object request failed: Underlying HTTP request operation failed with error: Error Domain=org.restkit.RestKit.ErrorDomain Code=-1011 "Expected status code in (200), got 401" UserInfo={NSLocalizedRecoverySuggestion={"timestamp":"2016-02-11T06:37:45.103+0000","status":401,"error":"Unauthorized","message":"Failed authenticating with username and password","path":"/api/v1/authenticate"}, NSErrorFailingURLKey=https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate, AFNetworkingOperationFailingURLRequestErrorKey= { URL: https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate }, AFNetworkingOperationFailingURLResponseErrorKey= { URL: https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate } { status code: 401, headers {
"Cache-Control" = "no-cache, no-store, max-age=0, must-revalidate";
"Content-Length" = 171;
"Content-Type" = "application/json;charset=UTF-8";
Date = "Thu, 11 Feb 2016 06:37:44 GMT";
Expires = 0;
Pragma = "no-cache";
Server = "";
"Set-Cookie" = "VCAP_ID=7487ff5a5d1940b895d0459b91eaec009a55f1ebd2774084b28fc6d24cab0f01; Path=/; HttpOnly";
"Strict-Transport-Security" = "max-age=31536000 ; includeSubDomains";
"Www-Authenticate" = "Basic realm=\"DEEPFIELD\"";
"X-Application-Context" = "gateway-dev:dev,cloud:0";
"X-Cf-Requestid" = "b0f1e586-8b60-4413-646d-515dbbe1f097, 954fd628-3beb-4777-41be-4eb50221b808";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = DENY;
"X-Xss-Protection" = "1; mode=block";
} }, NSLocalizedDescription=Expected status code in (200), got 401}
2016-02-11 12:07:45.216 DeepField[7033:95645] E restkit.network:RKObjectRequestOperation.m:215 POST 'https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate' (401 Unauthorized / 0 objects) [request=0.9732s mapping=0.0000s total=0.9869s]: Error Domain=org.restkit.RestKit.ErrorDomain Code=-1011 "Expected status code in (200), got 401" UserInfo={NSLocalizedRecoverySuggestion={"timestamp":"2016-02-11T06:37:45.103+0000","status":401,"error":"Unauthorized","message":"Failed authenticating with username and password","path":"/api/v1/authenticate"}, NSErrorFailingURLKey=https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate, AFNetworkingOperationFailingURLRequestErrorKey= { URL: https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate }, AFNetworkingOperationFailingURLResponseErrorKey= { URL: https://myproject-dev.apps.mycompany-iot-cloud.com/api/v1/authenticate } { status code: 401, headers {
"Cache-Control" = "no-cache, no-store, max-age=0, must-revalidate";
"Content-Length" = 171;
"Content-Type" = "application/json;charset=UTF-8";
Date = "Thu, 11 Feb 2016 06:37:44 GMT";
Expires = 0;
Pragma = "no-cache";
Server = "";
"Set-Cookie" = "VCAP_ID=7487ff5a5d1940b895d0459b91eaec009a55f1ebd2774084b28fc6d24cab0f01; Path=/; HttpOnly";
"Strict-Transport-Security" = "max-age=31536000 ; includeSubDomains";
"Www-Authenticate" = "Basic realm=\"myproject\"";
"X-Application-Context" = "gateway-dev:dev,cloud:0";
"X-Cf-Requestid" = "b0f1e586-8b60-4413-646d-515dbbe1f097, 954fd628-3beb-4777-41be-4eb50221b808";
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = DENY;
"X-Xss-Protection" = "1; mode=block";
} }, NSLocalizedDescription=Expected status code in (200), got 401}
2016-02-11 12:07:45.216 DeepField[7033:94063] Error from server in Post Request
I just set header again for restkit httpclient and it starts working.
RKObjectManager* rkobjmanagerDF;
[[rkobjmanager.HTTPClient defaultHeaders] setValue:#"application/json" forKey:#"Content-Type"];
[[rkobjmanagerDF.HTTPClient defaultHeaders] setValue:#"application/json" forKey:#"Accept"];

QuickBlox v2.6 Facebook login issue

I have one issue facebook signing with quickblox api.
After getting AccessToken by using FBSDK.
[QBRequest logInWithSocialProvider:#"facebook" accessToken:accessToken accessTokenSecret:nil successBlock:^(QBResponse *response, QBUUser *user) {
} errorBlock:^(QBResponse *response) {}
i think facebook returns correct token string.
CAAVS4qDIQb4BAMS7pTl3P1EmtW1ZCOOpbTCQFWrBI8QsA7ufOTYapjF3rEpW1ojZChgOZB7mj6AWDocDSdtxFbksqP3FyZCIou6bUC6ON4ZCRFGPes6TBzufh68A9fBSSz6baTYCZCTIyZAoDhYdBZAvrHF3609cAiEZCesnWrtqYleqPv7YHIadrWf2x1oWItypF3V3pbDgsHd7MSSCcZBvK4yuHGeCUvf7qMPFznuRZCfwNCOcQBDU8ynHnzDPpnnhLEZD
[logInWithSocialProvider: accessToken: ...] function returns following error
[QBResponse], status: 422
2015-12-09 14:27:27.049 NudgeBuddies[2598:124844] [QBCore] Response error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: client error (422)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7ffde266ce40> { URL: https://api.quickblox.com/login.json } { status code: 422, headers {
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 47;
"Content-Type" = "application/json; charset=utf-8";
Date = "Wed, 09 Dec 2015 06:27:26 GMT";
"QB-Token-ExpirationDate" = "2015-12-09 08:27:26 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" = ab3443c24c0d5ee0a18d796eaf996cb7;
"X-Runtime" = "0.221723";
"X-UA-Compatible" = "IE=Edge,chrome=1";
} }, NSErrorFailingURLKey=https://api.quickblox.com/login.json, com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a7b22 62617365 223a5b22 4c6f6769 6e206f72 20656d61 696c2072 65717569 72656422 5d7d7d>, NSLocalizedDescription=Request failed: client error (422)}
Please Help me.
How can i solve this problem?
Regards.
In QuickBlox SDK 2.6.5 we have improved stability and we have enabled detail logging so you are able to see the reasons why problem happens.
QuickBlox has open source project Q-municate with Facebook login and you can check it by yourself.
Thanks!

Instagram API, AFNetworking 2.0 iOS client 400 error

I haven't changed anything in my app and my code seems to generate the proper URL with access token attached, but I am getting a 400 error bad request for the past day. It doesn't seem as if Instagram has changed the endpoint. Can someone help me decipher the error log to see if there is any usable info here to help me debug? Access Token x'd out.
Failure Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: bad request (400)"
UserInfo=0x9261450 {NSErrorFailingURLKey=https://api.instagram.com/v1/locations/search?lat=37.785834&lng=-122.406417&distance=50&access_token=XXXX, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x92627d0> { URL: https://api.instagram.com/v1/locations/search?lat=37.785834&lng=-122.406417&distance=50&access_token=XXXX }
{ status code: 400, headers {
"Cache-Control" = "private, no-cache, no-store, must-revalidate";
Connection = "keep-alive";
"Content-Language" = en;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 26 Aug 2014 05:19:53 GMT";
Expires = "Sat, 01 Jan 2000 00:00:00 GMT";
Pragma = "no-cache";
Server = nginx;
"Set-Cookie" = "csrftoken=26b1980509fc8303e630689c2d483074; expires=Tue, 25-Aug-2015 05:19:53 GMT; Max-Age=31449600; Path=/, ccode=US; Path=/";
"Transfer-Encoding" = Identity;
Vary = "Cookie, Accept-Language";
"X-Ratelimit-Limit" = 5000;
"X-Ratelimit-Remaining" = 4999;
} }, NSLocalizedDescription=Request failed: bad request (400)}

Request gives error "connect closed due to timeout"

I am using quickblox in my app
I am trying to retrieve a dialog with certain user IDs
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:#"occupants_ids" forKey:#[#([[[DataManager sharedCenter]chat_user]ID]), #(self.opponent.ID)]];
[QBChat dialogsWithExtendedRequest:dict delegate:self];
and the result is this:
2014-08-09 13:47:02.843 App New[8752:8e0b] Performing async request:
GET https://api.quickblox.com/chat/Dialog.xml
headers:{
"QB-SDK" = "iOS 1.9.1";
"Qb-Token" = verylongtokencensored;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
(
1434093,
1367118
) = "occupants_ids";
}
2014-08-09 13:47:02.848 App New[8752:8e0b] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "max-age=0, private, must-revalidate";
Connection = "keep-alive";
"Content-Type" = "application/xml; charset=utf-8";
Date = "Sat, 09 Aug 2014 10:47:02 GMT";
Etag = "\"0c1aa29ff51b425a9be969d4fbb487a1\"";
"QB-Token-ExpirationDate" = "2014-08-09 12:47:02 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "201 Created";
"Transfer-Encoding" = Identity;
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 2330d50ea8c08851cafd30ea4c1a1c6b;
"X-Runtime" = "0.022278";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
<?xml version="1.0" encoding="UTF-8"?>
<session>
<_id>53e5fc26535c12a2f700aa3c</_id>
<application-id type="integer">10910</application-id>
<created-at type="datetime">2014-08-09T10:47:02Z</created-at>
<device-id type="integer">0</device-id>
<nonce type="integer">399</nonce>
<token>verylongtokencensored</token>
<ts type="integer">1407581207</ts>
<updated-at type="datetime">2014-08-09T10:47:02Z</updated-at>
<user-id type="integer">1434093</user-id>
<id type="integer">54616</id>
</session>
error:
2014-08-09 13:47:02.852 App New[8752:60b] received result:QBDialogsPagedResult,success:0,status:0
2014-08-09 13:47:02.852 App New[8752:8e0b] Request finished, response:
headers:(null)
body:
error:
2014-08-09 13:47:02.853 App New[8752:60b] Errors=(
"Connection closed due to timeout. Please check your internet connection."
)
How do i fix this error ?
Other requests sent to the api, which is not /chat/Dialog.xml they work fine, no connection timeout error
The right way is to use filter all:
[dict setObject:#"33,55" forKey:#"occupants_ids[all]"];
this will found all the dialogs where occupants_ids = "33,55"
you also can use filter in:
[dict setObject:#"33" forKey:#"occupants_ids[in]"];
this will return all the dialogs where occupants_ids contains 33
my bad my request had setObject forKey turned around, it should have been
[dict setObject:#[#([[[DataManager sharedCenter]chat_user]ID]), #(self.opponent.ID)] forKey:#"occupants_ids" ];

Quickblox: an issue in deleting content item (picture file / blob)

I am having a weird issue when I try to delete a content item (picture blob item for the user), stored as PNG picture file in the back-end database.
The delete proceeds without errors, but gives "422 Unprocessable Entity". What does this mean? The status of the content item seems to be OK and ready when checked in Quickblox admin panel.
I have uploaded the content with following API call:
[QBContent TUploadFile:imageData fileName:#"profile.png" contentType:#"image/png" isPublic:YES delegate:self];
I am trying to delete the object with following API call:
[QBContent deleteBlobWithID:blobID delegate:self];
QB logs:
Performing async request:
DELETE http://api.quickblox.com/blobs/91049.xml
headers:{
"QB-SDK" = "iOS 1.8";
"Qb-Token" = b9e3d1cc708c8444070544df8c642ad194509e67;
"QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:
2013-12-12 14:33:52.328 QBTestApp[21095:6b73] Request finished, response:
headers:{
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 49;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Thu, 12 Dec 2013 13:33:58 GMT";
"QB-Token-ExpirationDate" = "2013-12-12 15:32:22 UTC";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "nginx/1.0.15";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 3f235134e5aa0bd012ef78e54cddc164;
"X-Runtime" = "0.039680";
"X-UA-Compatible" = "IE=Edge,chrome=1";
}
body:
error:
<?xml version="1.0" encoding="UTF-8"?>
<errors/>
Any ideas what I might be doing wrong here? Thanks (again) in advance! :-)
The feeling that you are trying to delete a blob file that does not exisе. Please make sure that you are trying to delete a blob file after the upload and the creation process is completed(calling completedWithResult: with successful result).
If I could see the order of method calls TUploadFile: and deleteBlobWithID: in the code, I could help you more quickly.

Resources