I'm developing a social app. For current user, I need to randomly show other users of the app.
I first want to use this code to get the number of users:
PagedRequest *request = [PagedRequest new];
request.perPage = 1;
request.page = 1;
[QBUsers usersWithPagedRequest:request delegate:self.proxy];
I noticed that this is the XML returned:
<users type="array" current_page="1" per_page="1" total_entries="13">
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2013-07-24T06:16:13Z</created-at>
<email>xxxxxx@xx.com</email>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name>XXX xxx</full-name>
<id type="integer">236286</id>
<last-request-at type="datetime">2013-11-15T06:27:09Z</last-request-at>
<login>t2wu</login>
<owner-id type="integer">4282</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2013-11-15T06:27:09Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
</users>
My intention is to get the 13 from the "total_entries=13", so I know that the total number of users, then make a request like this again:
PagedRequest *request = [PagedRequest new];
request.perPage = 1;
request.page = [self randomAmong: 13];
[QBUsers usersWithPagedRequest:request delegate:self.proxy];
where [self randomAmong: 13]
just pick one number out of 1 and 13, then grab the user's profile picture and show it to the current user.
Three questions:
Although I can see the number 13 in the XML in the console output, I have no idea how to get that number.
I only want to rotate through my mobile application users, not my developer's account (the account user). QuickBlox allows multiple applications associated with one QuickBlox account user; however, all users seems to be lumped together. Although I could make sure that I only have one application inside this account, I still need to be able to exclude myself from it.
This is a relatively minor question. Although the above attempt to get the current number of users is not an attempt to log in, the delegate method
-(void)completedWithResult:(Result*)result
has result as a class ofQBUUserLogInResult
. I don't understand why it is, why isn't itQBUUserPagedResult
orQBUUserResult
which seems to make more sense?
Thanks.
This is a right way, here are the answers for your questions:
1)
2)
You can use tags to separate users. While user sign up - just add a tag to this user, for example 'app1'.
Next - to retrieve users with tag 'app1' - use the next query:
3)
User login query will return 'QBUUserLogInResult' result
Get single user query will return 'QBUUserResult' result
Get multiple users query will return 'QBUUserPagedResult' result