How to access all users using Rosters in XMPP ejabberd server - xmpp

I am half way doing chat using XMPP. I have registered and logged in to ejabberd server.
I can see in web interface that there are 10 registered users and 4 online users. But Roster delegates not getting any contacts.
I have tried this solution. I did not get any results.
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{
NSXMLElement *queryElement = [iq elementForName: #"query" xmlns: #"jabber:iq:roster"];
if (queryElement) {
NSArray *itemElements = [queryElement elementsForName: #"item"];
[ArrayUsers removeAllObjects];
for (int i=0; i<[itemElements count]; i++) {
NSString *jid=[[[itemElements objectAtIndex:i] attributeForName:#"jid"] stringValue];
[ArrayUsers addObject:jid];
}
}
return NO;
}
What may be the issue ? Do I have to configure the server settings for this to get contacts. It will be accessible to all by default?
Or, do i have to make a query to get the user details and automatically synced to CoreData storage.
Any help will be much appreciated.

The issue was that the shared roster module was not enabled in ejabberd configuration file. You can just enable mod_shared_roster in your ejabberd config modules section (the people who know how to do will understand. I personally dont know! So seeked help from others in the company).
Then, the shared Roster option will be available in the web interface of the admin side of ejabberd server.
Now configure the server to see all users to be seen for every body using the following link:
ejabbered configuration
Now, if you have logged in and set for automatic sync of Roster (XMMP framework by RobbieHanson Eg), you will get all users in the list.

Create a Shared Roster and get all users from the Roster. Check this

Related

NSSharingService by Facebook in Mac app with no account configured

I am trying to share a link in an Mac App in Facebook/twitter and I would like to check if the user has the account in settings. If the account is not in settings, I would like to do this sharing by web browser.
I try the following code, because Apple documentation said that you can check if the account is configured using canPerformWithItems with the nil parameter. (facebookSharingService is NSSharingService)
NSMutableArray *shareItems = [self prepareItemsToMessage];
if ([self.facebookSharingService canPerformWithItems:nil])
{
/*
Perform the service using the array of items.
*/
[self.facebookSharingService performWithItems:shareItems];
}
else
{
[self shareFacebookByWebBrowser];
}
Using this code, pop up appears saying that I need to configure the account. How can I check if the account of Facebook or Twitter in in Settings or not?

I can't get the mail list by using mailcore

These days ,I am working a mail client by using the mailcore.Everytime, Successfully connected to the imap server,but I can't get the INBOX list.The key code
CTCoreFolder *inbox = [account folderWithPath:#"INBOX"];
NSArray *messageList = [inbox messagesFromSequenceNumber :1 to:0 withFetchAttributes:CTFetchAttrEnvelope];
NSLog(#"%d",[messageList count]);
Evertime ,the output is 0;I do this is wrong ?
Why not to use Address Book API ?
Here are some answers:
iOS how to get Email contacts from Mails app?
Get all E-Mail addresses from contacts (iOS)

iOS 6 - Facebook sharing procedure fails with error "The proxied app is not already installed"

Though, there is such a question Facebook Error (7) iOS 6 it's already closed without any answer!
While obtaining an access to user's facebook account I've got an error:
error is: Error Domain=com.apple.accounts Code=7 "The Facebook server could not fulfill this access request: The proxied app is not already installed." UserInfo=0xa260270 {NSLocalizedDescription=The Facebook server could not fulfill this access request: The proxied app is not already installed.}
I'm performing a request like this:
self.statusLabel.text = #"Waiting for authorization...";
if (self.accountStore == nil) {
self.accountStore = [[ACAccountStore alloc] init];
}
ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary * dict = #{ACFacebookAppIdKey : FB_APP_ID, ACFacebookAudienceKey : ACFacebookAudienceEveryone};
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
__block NSString * statusText = nil;
if (granted) {
statusText = #"Logged in";
NSArray * accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
NSLog(#"account is: %#", self.facebookAccount);
self.statusLabel.text = statusText;
[self postToFeed];
}
else {
self.statusLabel.text = #"Login failed";
NSLog(#"error is: %#", error);
}
}];
What does this error means?
I've solved this problem!
It was because I do not pass permissions array!
Though the ACAccountStore class states that this parameter is optional, it is not!
More over the application could launch and ask for basic permissions(as it is implied)!
So, you must always pass a permissions array.
Here's also a description of error codes returned by account store:
typedef enum ACErrorCode {
ACErrorUnknown = 1,
ACErrorAccountMissingRequiredProperty,
ACErrorAccountAuthenticationFailed,
ACErrorAccountTypeInvalid,
ACErrorAccountAlreadyExists,
ACErrorAccountNotFound,
ACErrorPermissionDenied,
ACErrorAccessInfoInvalid
} ACErrorCode;
(I've got ACErrorPermissionDenied here)
We had the same problem and after taking a closer look at the iOS facebook documentation ad
https://developers.facebook.com/docs/howtos/ios-6/
I noticed the following paragraph:
Note, to use iOS 6 native auth, apps need change the way they request permissions from users - apps must separate their requests for read and write permissions.
I must have read over that one several time but it contained the solution:
You have to do multiple request for access if you want to grant write (publish access). So now we first ask for permission 'email' to get read permission and then for 'publish_action' to be able to post to the timeline.
The error message is not clear since "app" could be your iOS app? Facebook.app on the phone? Facebook app? The "proxied app" is the Facebook app, and "not already installed" means, it's not yet been associated with the Facebook user online in terms of permissions.
The first time your Facebook app connects to the users Facebook account, you must specify the basic info value(s) in your ACFacebookPermissionsKey key of the options dictionary. Other Facebook SDK's past and present such as the Javascript or PHP libraries by default supply basic info as the key, so you never had to. It seems the native integration in iOS doesn't do this, thus, if when the user first connects your app to their Facebook account with no permissions supplied, you get this error.
After you are given access, i.e. - after the user is connected to the app in their privacy settings online, ACFacebookPermissionsKey does as Apple document, become optional.
It's all a little confusing when you start to try and use the native Facebook integration...
Using the native Facebook integration you must provide one of the following keys which are basic info keys: email, user_birthday, or user_location.
To quote Facebook (source):
To create this basic connection using the iOS 6 native Auth Dialog,
apps must request access to a user's basic profile information by
asking for one of email, user_birthday, or user_location permissions.
After experiencing this error on one of my devices (after seeing the correct, expected iOS alert view asking for me to approve Facebook access to my app):
'The Facebook server could not fulfill this access request: Invalid application ID.'
I finally found the problem.
Although it initially appears to be a problem with the Facebook app setup on the FB developer site it turned out that my device's iOS Facebook account no longer had a valid password associated with it - this can happy when users restore an iOS backup to a new device. Once I sorted that in my device settings everything worked as expected.
I've not experienced any problems requesting 'publish_stream' in the first FB permissions access request - I actually think the real problem here is that the error messages are so random that they don't help developers to locate the source of the errors we're experiencing thanks to Apple and Facebook's lack of unity!
A few more things that one can try other than the above suggestions is checking your app settings on facebook.com here -
https://developers.facebook.com/apps/<*APP_ID*>/summary
Make sure that the SandBox Mode is set to Off
Also,
Under "Select how your app integrates with Facebook"
Select-> Native iOS App
Set your Bundle ID
You can set any temporary integer value for iPhone/iPad App store ID
Set Facebook login to Enabled
Listed Platforms is Native iPhone App &/or Native iPad App
Save changes and try after some time as it might take a few minutes for facebook to sync the changes to all its servers.

manage friends using xmpp in iphone sdk?

Topic:
hi, i want to develop xmpp chat application, so far i have done with xmpp chatting, ie. sending and receiving messages to online users. but how can i add another online user as a buddy/friend ? and how can i remove friend from my friend list (using xmpp) ?? and how to know that someone has sent me a friend request (in xmpp)
Technology: iphone applcation programming
Language: Objective C
The XMPP server manages your buddy list (roster management), so you have to send the Subscribe/Unsubscribe packets to the XMPP server to add or remove buddies. Please see the section 8.2 in XMPP RFC (rfc-3921) for the format of XMPP message that you have to send and server response that you have to handle.
Here is the link to XMPP RFC (see section 8.2)
http://xmpp.org/rfcs/rfc3921.html
Use below code to send buddy request.Its working for me currently. username ot email id depends on your openfire settings.
XMPPJID *newBuddy = [XMPPJID jidWithString:#"friendsemailid or username"];
[xmppRoster addUser:newBuddy withNickname:nil];
1.You can add a new friend through this code in didReceivePresence delegate
else if ([presenceType isEqualToString:#"subscribe"])
{
NSXMLElement *presenceToRequest = [NSXMLElement elementWithName:#"presence"];
[presenceToRequest addAttributeWithName:#"type" stringValue:#"subscribed"];
[presenceToRequest addAttributeWithName:#"to" stringValue:[NSString stringWithFormat:#"%#", [presence fromStr]]];
[presenceToRequest addAttributeWithName:#"from" stringValue:[NSString stringWithFormat:#"%#", [presence toStr]]];
[[self xmppStream] sendElement:presenceToRequest];
}
2.You can send friend request through XMPPRoster method
[xmppRoster addUser:[XMPPJID jidWithString:friendJID] withNickname:friendNickName];
3.In didReceivePresence delegate you can your friend request either you want to accept or reject a friendrequest.
I hope this information helps you to solve your issues.enter code here

AddressBook: how to get names of different Exchange sources

I want to get the name of all the Exchange sources that my iPhone is synced to. For e.g. if I sync my device to Gmail and Hotmail accounts using ActiveSync Exchange, in the native contacts, I can see different sections based on the different accounts that I have setup. When I try to programmatically do the same, the only information I get is sourceType (which is Exchange in both cases) and sourceName (which is "Contacts" in both cases). There's no way for me to differentiate which is the Gmail "Contacts" and which is the Hotmail "Contacts".
Anyone know how to do this? Here's my code:
CFArrayRef allSources = ABAddressBookCopyArrayOfAllSources(book);
for (CFIndex i = 0; i < CFArrayGetCount(allSources); i++) {
ABRecordRef source = (ABRecordRef)CFArrayGetValueAtIndex(allSources, i);
NSString *sourceTypeName = (NSString *)((CFStringRef)ABRecordCopyValue(source, kABSourceNameProperty));
NSLog(#"%#", sourceTypeName);
}
You can't do this in iOS it seems (yet)