2
votes

I am developing an iOS application which uses the Facebook chat feature.

(I am using the XMPPFramework by Robbie Hanson).

https://github.com/robbiehanson/XMPPFramework

In connect method i have given my user name and password

- (BOOL)connect
{
    if (![xmppStream isDisconnected]) {
        return YES;
    }

    NSString *myJID = [[NSUserDefaults standardUserDefaults] stringForKey:kXMPPmyJID];
    NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:kXMPPmyPassword];

    //
    // If you don't want to use the Settings view to set the JID, 
    // uncomment the section below to hard code a JID and password.
    // 

     myJID = @"[email protected]";
     myPassword = @"Mypassword";

    if (myJID == nil || myPassword == nil) {
        return NO;
    }

    [xmppStream setMyJID:[XMPPJID jidWithString:myJID]];
    password = myPassword;

    NSError *error = nil;
    if (![xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error connecting" 
                                                            message:@"See console for error details." 
                                                           delegate:nil 
                                                  cancelButtonTitle:@"Ok" 
                                                  otherButtonTitles:nil];
        [alertView show];

        DDLogError(@"Error connecting: %@", error);

        return NO;
    }

in up stream method i have given my host name and port number

- (void)setupStream
{
    NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times");


    xmppStream = [[XMPPStream alloc] init];

    #if !TARGET_IPHONE_SIMULATOR
    {


        xmppStream.enableBackgroundingOnSocket = YES;
    }
    #endif



    xmppReconnect = [[XMPPReconnect alloc] init];



    xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init];


    xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];

    xmppRoster.autoFetchRoster = YES;
    xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;



    xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
    xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];

    xmppvCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:xmppvCardTempModule];


    xmppCapabilitiesStorage = [XMPPCapabilitiesCoreDataStorage sharedInstance];
    xmppCapabilities = [[XMPPCapabilities alloc] initWithCapabilitiesStorage:xmppCapabilitiesStorage];

    xmppCapabilities.autoFetchHashedCapabilities = YES;
    xmppCapabilities.autoFetchNonHashedCapabilities = NO;

    // Activate xmpp modules

    [xmppReconnect         activate:xmppStream];
    [xmppRoster            activate:xmppStream];
    [xmppvCardTempModule   activate:xmppStream];
    [xmppvCardAvatarModule activate:xmppStream];
    [xmppCapabilities      activate:xmppStream];

    // Add ourself as a delegate to anything we may be interested in

    [xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
    [xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];


    [xmppStream setHostName:@"chat.facebook.com"];
    [xmppStream setHostPort:5222];


    // You may need to alter these settings depending on the server you're connecting to
    allowSelfSignedCertificates = NO;
    allowSSLHostNameMismatch = NO;
}

Is there any steps that I have missed out? I have no idea how to proceed further. Help me if any one know the solution. Please help me out Thanks in advance.

1
As i see you only changed the sample project of the library. Were you able to see your chat friends when you set these parameters?ismailgulek
Even my friends list is not showing in the app. kindly help me to move forward with any good tutorials tutorials.Peer Mohamed Thabib
Your friend list should be shown when you set them in the Settings page in the sample application. Try not setting hostName. You need to get started with XMPP documentation: http://xmpp.org/xmpp-protocols/xmpp-core/ismailgulek
And here some books listed: http://xmpp.org/resources/books/. Maybe you want to get one of them.ismailgulek
Did you look over the Facebook api on this? developers.facebook.com/docs/chat .smileBot

1 Answers

1
votes

Try securing the connection using:

[xmppStream secureConnection:(NSError *)];

in the

 - (void)xmppStreamDidConnect:(XMPPStream *)sender; 

delegate method.

Hope it helps.