List of chat room members - iphone

How can I retrieve the list of members of a chat room in using XMPP framework?
I tried using:
- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items
But it returns an empty array

This question is old but I recently encountered this exact issue (xmppRoom:didFetchMembersList: is passed an empty array). In my case the problem was that when users got invited to the room they would have a role of "participant" and an affiliation of "none". The fetchMembersList method in XMPPRoom looks for items with an affiliation of "member".
You can change the affiliation like so:
[xmppRoom editRoomPrivileges:#[[XMPPRoom itemWithAffiliation:#"member" jid:userJID]]];
For details on roles and affiliations, see XEP-0045.

use this method when you invite users.
-[xmppRoom editRoomPrivileges:#[[XMPPRoom itemWithAffiliation:#"member" jid:userJID]]];
After you create xmpproom object and call following delegate method
-(void)xmppRoomDidJoin:(XMPPRoom *)sender{
[sender fetchMembersList];
}
- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items{
NSLog(#"print user list=====%#",items);
for (NSXMLElement *xmlItem in items) {
NSString *jid = [[xmlItem attributeForName:#"jid"]stringValue];
NSLog(#"print user jid=====%#",jid);
}
}

Related

How to send custom string with QBRTCSession object

In my application I have implemented quickblox SDK for voice and video call and everything is working perfectly. There is just one issue which I am facing. To track the particular call in background I have a session created between two users. But while making this call I want to send the same session Id to the opponent also. If somebody could help me please tell me how could i do this.
Thanks in advance
Got the solution!!
Refer http://quickblox.com/developers/Sample-webrtc-ios
Before making a call I have following line of code written in my file
[self.session startCall:userInfo];
Here you can write anything inside userInfo dictionary. As soon as opponent receives the call
- (void)didReceiveNewSession:(QBRTCSession *)session userInfo:(NSDictionary *)userInfo
will be called. Here whatever you have written inside userInfo, you can read it directly.
[QBRTCClient.instance addDelegate:self];
// 2123, 2123, 3122 - opponent's
NSArray *opponentsIDs = #[#3245, #2123, #3122];
QBRTCSession *newSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs
withConferenceType:QBConferenceTypeVideo];
// userInfo - the custom user information dictionary for the call. May be nil.
NSDictionary *userInfo = #{ #"key" : #"value" };
[newSession startCall:userInfo];
Start call method definition says the same
/**
* Start call. Opponent will receive new session signal in QBRTCClientDelegate method 'didReceiveNewSession:userInfo:
*
* #param userInfo The user information dictionary for the stat call. May be nil.
*/
- (void)startCall:(NSDictionary *)userInfo;

FBWebDialog without friend list

In my app I want to use FBWebDialog to send "app request" to the multiple users. But I dont want to select those users from the list which comes with the FBWebDialog. I just want to pass the friends from the FBfriendpicker viewcontroller to the FBWebDialog and send them from there. is it possible? How can I do that? Thanks.
You need to set the "to" parameter as documented in two pages referenced below, it will disable the drop down friend list and send to only one targeted audience
https://developers.facebook.com/docs/howtos/send-requests-using-ios-sdk/
Sending targeted requests
You can filter the suggested list down or target one user. To filter
down the list you can pass in a parameter, suggestions that contains a
comma-separated list of friends to show in the selection. To target
one recipient, pass that user's ID in a to parameter
And also documented on request dialog page
to A user ID or username, or a comma-separated list of them. These may
or may not be a friend of the sender. If this is specified by the app,
the sender will not have a choice of recipients. If not, the sender
will see a multi-friend selector and will be able to select a maximum
of 50 recipients. (Due to URL length restrictions, the maximum number
of recipients is 25 in IE7/IE8 when using a non-iframe dialog.)
Another documentation in games section of facebook with picture
https://developers.facebook.com/docs/tutorials/ios-sdk-games/requests/
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// 2. Optionally provide a 'to' param to direct the request at
#"286400088", #"to", // Ali
nil];
Upgrad from 3.2 to 3.5.1 in part to allow me to use frictionless friend requests. The process works fine with:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
FBFrictionlessRecipientCache *friendCache = [[FBFrictionlessRecipientCache alloc] init];
[friendCache prefetchAndCacheForSession:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:[FBSession activeSession]
message:[NSString stringWithFormat:#"I just posted an action - give me some points!"]
title:#"Get Points from your friends"
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Case A: Error launching the dialog or sending request.
NSLog(#"Error sending request.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// Case B: User clicked the "x" icon
NSLog(#"User canceled request.");
} else {
NSLog(#"Request Sent.");
}
}}
friendCache:friendCache];
This helps you to upgrade your Facebook sdk https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.2-to-3.5/

Accessing GTLPlusActivity properties

I have integrated the Google Plus iOS SDK v1.2.1 into my iOS app. After authentication I am trying to fetch the user's activity feed. My code is the following:
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
plusService.retryEnabled = YES;
GTLQueryPlus *query = [GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:kGTLPlusCollectionPublic];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *data,
NSError *error) {
for (GTLPlusActivity *activity in data.items) {
// ITERATE THROUGH THE ACTIVITIES
NSString *publishedDate = activity.published; <---- ERROR
// "PROPERTY 'published' CANNOT BE FOUND
// IN FORWARD CLASS OBJECT "GTLPLusActivity""
// WHY ARE THE VARIABLES SUCH AS published, placeName,
// title, actor etc NOT ACCESSIBLE
}
}];
I am able to successfully retrieve the posts of the user. The GTLPlusActivity class has many properties as shown in the image:
Whenever I try to access the properties using the "." operator such as "activity.actor" in the for loop, it gives the error "Property 'actor' cannot be found in forward class object 'GTLPlusActivity'". Why am I unable to access the properties? I need to display them in a UITableView.
EDIT: Code Snapshot. Error clearly displayed in Red.
Firstly, check the error condition and make sure the error code is nil. I have tried your code, and it works correctly on my end, so most likely, there is a problem with the response you are getting back. Generally activity.actor will return a GTLPlusActivityActor.
Try something like:
if (error) {
NSLog(#"Status: Error: %#", error);
}
else
<Do stuff>
EDIT: Also, our iOS quick-start is a great resource for seeing how we handle certain parts of the code. The ListMoments bit is pretty similar to dealing with Activities.
https://developers.google.com/+/quickstart/ios
EDIT 2: Also, make sure you have all of the right imports. Try
#import "GTLPlusActivity.h"
or
#import "GTLPlus.h"

iOS facebook check if friends have app installed [duplicate]

This question already has answers here:
Facebook Graph API - Friends using application
(2 answers)
Closed 5 years ago.
Is there already a way with the facebook ios API to get a list of friends who have your app installed? I basically require something similar to "Words with Friends" where they can determine which of your FB friends are playing the game. I have one solution which requires some extra database use but was hoping maybe the FB api had something built in for this kind of query.
Create a FBFriendPickerDelegate delegate class and override this function:
-(BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user{
BOOL installed = [user objectForKey:#"installed"] != nil;
return installed;
}
For users that do not have your app installed, installed field will be nil, but you have to request it when you load data:
self.friendsController = [[FBFriendPickerViewController alloc] initWithNibName:nil bundle:nil];
//...
NSSet *fields = [NSSet setWithObjects:#"installed", nil];
self.friendPickerController.fieldsForRequest = fields;
//...
[self.friendsController loadData];
I think fql is a little complex for me,so I use this function in FBRequest to call the Graph API to solve this problem in Facebook SDK 3.5
+ (FBRequest *)requestWithGraphPath:(NSString*)graphPath parameters:(NSDictionary*)parameters HTTPMethod:(NSString*)HTTPMethod;
And the code is:
FBRequest *request = [FBRequest requestWithGraphPath:#"me/friends"
parameters:#{#"fields":#"name,installed,first_name"}
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBRequestConnection *connection,
id result,
NSError *error){
}];
You can put all your interesting fields in the parameters dictionary.
And according to the SDK Reference,object containing type (this is always "user"), id (the ID of the user), and optional installed field (always true if returned); The installed field is only returned if the user has installed the application, otherwise it is not part of the returned object
I've used this code in the past to get app using friends from a user.
facebook is the Facebook class that comes with FB Connect.
NSString *fql = [NSString stringWithFormat:#"SELECT name,uid, pic_small FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = %#) order by concat(first_name,last_name) asc",userId,userId]];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:fql ,#"query", [facebook accessToken], #"access_token", nil];
[facebook requestWithMethodName:#"fql.query" andParams:params andHttpMethod:#"GET" andDelegate:self];
The easiest solution is using the
- (BOOL)friendPickerViewController: shouldIncludeUser:
method implemented by the FBFriendPickerDelegate protocol in the latest 3.5.1 Facebook SDK (June 2013), asking the delegate whether to include a friend in the list, based on the "installed" field when fetching me/friends.
The installed field is present (true) if the friend is also a user of the calling application.
You can use like this:
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
shouldIncludeUser:(id <FBGraphUser>)user {
return [[user objectForKey:#"installed"] boolValue];
}
IMPORTANT!
You have to include the followings to include the field in the request and to inform friendPicker about its delegate:
self.fieldsForRequest = [NSSet setWithObject:#"installed"];
self.delegate = self;
You can verify with the Graph Api Explorer that only friends with the apps installed display by using the Graph API Explorer and entering the query
me/friends?fields=installed
and you can get back a list of your friends like this, where one of the user has installed your application (true):
...
{
"id": "100002656xxxxxx"
},
{
"installed": true,
"id": "100004366xxxxxx"
},
...

Having two Facebook request paths in same controller iOS SDK

I am having a controller where I need issue multiple facebook requests. How do I tell the request appart in this delegate method?
- (void)request:(FBRequest *)request didLoad:(id)result { ... }
I need to do one thing for one request and another thing for the other request.
How about write individual class request & results from delegates , i used to try this when in Single View i need to take Friends List, Checkins Data , User Info.
i ll create three separate delegate results & get results back .
However making multiple requests will work but it will create bad performances when any one of the requests failed or goes wrong.
Hope it helps
Updated :
userInfo *uInfo = [UserInfo alloc]init];
[uinfo getuserDetails];
[uInfo release];
create a protocol to return results of user info back to view class like
In UsuerInfo class
-(void)request:(FBRequest *)request didLoad:(id)result {
[delegate finfinishedGettingUserInfoDetails:result] // convert to array
}
IN your view class get back the results as
-(void)finishedGettingUserInfoDetails : (NSMutableArray *)userArr {
yourInstanceArray = [userArr copy];
}
do this for all multiple requests.