Search code examples
iosquickblox

Loading QBCOCustomObject after logging in


EDIT: I've found the solution.

The right magic word is: [QBCustomObjects objectsWithClassName:@"Settings" extendedRequest:(NSMutableDictionary*)@{@"user_id": [NSNumber numberWithInt:userID]} delegate:self];

I was fooled by QuickBlox web interface, I saw the field "User ID" but its' right name is "user_id". Igor, thanks for link: http://quickblox.com/developers/Custom_Objects#Module_description

After logging in I immediately try to load a custom object belongs to the user. Code:

[QBCustomObjects objectsWithClassName:@"Settings" extendedRequest:(NSMutableDictionary*)@{@"User ID": [NSNumber numberWithInt:userID]} delegate:self];

And I have this error:

Performing async request: 
RestRequest:
------
GET http://api.quickblox.com/data/Settings.xml
headers:{
    "QB-SDK" = "iOS 1.7.1";
    "Qb-Token" = 7cca2175045d14f5268d665b19e798f7240b5119;
    "QuickBlox-REST-API-Version" = "0.1.1";
}
parameters:{
    "User ID" = 503563;
}
raw body:
2013-09-10 14:54:30.771 DimChat[48597:6c0f] Request failed, response: 
RestResponse:
------
<QBASIHTTPRequest: 0x996ae00>
headers:(null)
body:
error:Error Domain=QBASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x7d693e0 {NSLocalizedDescription=Unable to create request (bad url?)}
2013-09-10 14:54:30.771 DimChat[48597:c07] (
    "Connection closed due to timeout. Please check your internet connection."
)

May be I do something wrong?

I can create a new custom object in user event handler and even I can (re)load the created object using it's ID

[QBCustomObjects objectWithClassName:@"Settings" ID:co.ID delegate:self];

But I need to load a custom object when I know only User ID and immediately after login.


Solution

  • There is a table with pre-defined fields explanation (in bold) http://quickblox.com/developers/Custom_Objects#Module_description