EzDevInfo.com

XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS

Storing messages using XMPPFramework for ios?

I'm not sure how to use the XMPPFramework's core data to store incoming messages. Does anyone have any tutorials on how to do this? I see User objects, which in turn can have many "resources". Is each message received supposed to be a new resource that I create and persist?

I do not know what part is my responsibility and what part the framework provides regarding message history. I can intercept every incoming message. Then am I supposed to create and store each message inside a Messages table using core data? I'd have a Message Entity. And each XMPPUser would have an array of Message objects. But then wouldn't I be rolling my own solution, which would be working against the framework?

Thanks!


Source: (StackOverflow)

Better Way to implement the chat application using XMPP on Android?

Hi i want to implement the Chat application in android using XMPP (To avoid the GCM notifications because GCM uses request response process).

i have done the 70 perc functionality using Smack library and OpenFire server. but after completion of these i came to know about the QuickBlox SDK. I don't know completely about that but few people are saying that it is good api by seeing the features..

can any one tell me that is it correct way of implementing the chat application using smack for xmpp . or we have any other good api which uses xmpp for android .


Source: (StackOverflow)

Advertisements

Build a chat application in ios using XMPP [closed]

I am trying to build a chat application in ios. I came across XMPP for ios. I am bit confused on how to move forward. Here are my doubts:

  1. Do I need to create an XMPP server to implement this application?
  2. Or are there any existing servers/services which can be used for the same purpose?

Source: (StackOverflow)

node js for XMPP protocol?

I want to develop an instant messaging for mobile application, like whatsapp, with nodejs as my backend. I have gone through XMPP protocols and read xmpp.org documentation as well.

I referred to this link and I am able to build some of the basic XMPP functionality like creating and messaging users. But I am still unable to implement the complete functionality of XMPP in nodejs.

So: are there any node js libaries available to build the complete functionality of xmpp protocol, such as asmack? Alternatively, how do I send calls to XMPP server via XML?


Source: (StackOverflow)

Enable BOSH services in XMPP IOS framwork(https://github.com/robbiehanson/XMPPFramework) to creat chat based app

I have implemented Chat based application.I can able to do many functionality with https://github.com/robbiehanson/XMPPFramework library. It is very good library. But after some days my server side guys included bash services in server. My server side guys implementing xmpp using Strophe.js. And they are using following code to enable BOSH service while connecting.

BOSH_SERVICE = "http://host.com:5280/http-bind";
new Strophe.Connection(BOSH_SERVICE);

Now they told me enable BASH service in IOS side also. Now I can not connect to that server. Please can anyboady help me to how to include BOSH service in robbiehanson xmpp IOS library(https://github.com/robbiehanson/XMPPFramework).

Really appreciate anykind of help on this topic.

Thanks


Source: (StackOverflow)

Using XMPP to send realtime-ish information to running iOS app

I'm developing an iOS app. There are different 'areas' to the app, and users can post 'things' to them. Other users watching the same area should have the posted thing sent to their phone (but only if the app is running).

I've started work on a Django backend with a RESTful API. I plan on hosting the backend on Amazon Web Services, and each time something is added to an 'area', placing the time of update and 'area' into a queue, using Amazon Simple Queue Service. I'm going to make a Python app that processes items in the queue, querying the database to see which users have new 'things' they can download - currently this part is planned to then send an Apple Push Notification to the phone, and if the app is running it can make a simple RESTful request to get the new data in JSON format.

However I believe XMPP would be a better solution (using XMPPFramework on the iOS side), and would make it possible to support Android in the future.


I've done a lot of research into how to use XMPP for this purpose, but the documentation suggests that you would be using the public XMPP network, that users would have to set up an XMPP account, and is unclear how to send non-chat information.

This project requires the use of XMPP purely to send information from the server to a users device. Thus it should be a private XMPP network, if necessary users can be registered for an XMPP account on this private network (but behind the scenes, they shouldn't know what technology is powering the app.)


Is it possible to use XMPP just to send information to a mobile app? A lot answers/tutorials on the internet basically just suggest using an XMPP server and client - with no mention of how you can hook up the two on a private network to send data as determined by something other than the XMPP server.

Thank you for your help in advance :)


Source: (StackOverflow)

How to get the message delivary status using XMPP framework

I am using the XMPP Framework for chatting between the users , Chatting is happening perfectly .Now I need to show the message is delivered perfectly to both devices like (What's app messenger). I am not getting any tutorial to follow. Below code represents while we send message to the other user.

//Sending the message to the other user
 NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
 [body setStringValue:txtChat.text];

 NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
 [message addAttributeWithName:@"type" stringValue:@"chat"];
 [message addAttributeWithName:@"to" stringValue:self.userjid];
 [message addChild:body];
 [[APPDELEGATE xmppStream] sendElement:message];

While reterving the message by using XMPP Framework i was getting the data by using below code

- (void)loadarchivemsg
{        
    XMPPMessageArchivingCoreDataStorage *storage = [XMPPMessageArchivingCoreDataStorage sharedInstance];
    NSManagedObjectContext *moc = [storage mainThreadManagedObjectContext];
    NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"XMPPMessageArchiving_Message_CoreDataObject"
                                                         inManagedObjectContext:moc];
    NSFetchRequest *request = [[NSFetchRequest alloc]init];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(bareJidStr like %@) && (streamBareJidStr like %@)", self.userjid,[[NSUserDefaults standardUserDefaults] stringForKey:@"kXMPPmyJID"]];
    request.predicate = predicate;
    NSLog(@"%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"kXMPPmyJID"]);
    [request setEntity:entityDescription];
    NSError *error;
    NSArray *messages_arc = [moc executeFetchRequest:request error:&error];

    [self print:[[NSMutableArray alloc]initWithArray:messages_arc]];    
}

- (void)print:(NSMutableArray*)messages_arc{
    @autoreleasepool {
        for (XMPPMessageArchiving_Message_CoreDataObject *message in messages_arc) {

            NSXMLElement *element = [[NSXMLElement alloc] initWithXMLString:message.messageStr error:nil];
            XMPPMessage *message12=[[XMPPMessage alloc]init];
            message12 = [message message];
  }
}

In this why I was sending the message and retrieving the message,can you help me how to retrieve the delivery status of the message . Waiting for your valuable answers.


Source: (StackOverflow)

How to use a TurnSocket (XEP-0065: SOCKS5 Bytestreams) connection? XEP-0096: SI File Transfer? [socket writeData]?

I'm attempting file transfer via XMPP on iOS using the XMPPFramework and OpenFire. The base of my code is from the following tutorial. I have a successful TurnSocket (XEP-0065: SOCKS5 Bytestreams) connection, but I can't work how to use it to send data. There are 2 considerations I have, both of which I am stuck on: 1. Calling [socket writeData] and 2. Using 'XEP-0096: SI File Transfer'.

Possible solution 1 - Calling [socket writeData] In my App delegate I have a didSucceed method. I can call [socket writeData] like this ...

- (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket {

    NSLog(@"TURN Connection succeeded!");

    [socket writeData:myData withTimeout:60.0f tag:0]; 
    [turnSockets removeObject:sender];
}

Updated 14th June : Is this correct? If so, how does the other user read the data? I have tried implementing

- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag

but it never gets called. How do I ensure it gets called?

Possible solution 2 - XEP-0096: SI File Transfer Do I need to use XEP-0096: SI File Transfer? If so, how do I use my successful connection within the XEP-0096 XML I need to form? The XEP-0096 docs imply there is a 'hash' attribute, but I don't know where this comes from.

e.g.

<iq type='set' id='offer1' to='receiver@jabber.org/resource'>
  <si xmlns='http://jabber.org/protocol/si' 
      id='a0'
      mime-type='text/plain'
      profile='http://jabber.org/protocol/si/profile/file-transfer'>
    <file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
          name='test.txt'
          size='1022'
          hash='552da749930852c69ae5d2141d3766b1'
          date='1969-07-21T02:56:15Z'>
      <desc>This is a test. If this were a real file...</desc>
    </file>
    <feature xmlns='http://jabber.org/protocol/feature-neg'>
      <x xmlns='jabber:x:data' type='form'>
        <field var='stream-method' type='list-single'>
          <option><value>http://jabber.org/protocol/bytestreams</value></option>
          <option><value>http://jabber.org/protocol/ibb</value></option>
        </field>
      </x>
    </feature>
  </si>
</iq>

Source: (StackOverflow)

XMPP frameworks

.h and .m files of the xmpp, I am trying work on a chat application.
But when i build the project I get the following error, I am trying to solve the problem from past 24 hours, but was not successful to get the solution, I even googled but didn't got the solution. The following is the error which i am getting,

Undefined symbols for architecture i386:
  "_dns_free_resource_record", referenced from:
      -[XMPPSRVResolver processRecord:length:] in XMPPSRVResolver.o
  "_dns_parse_resource_record", referenced from:
      -[XMPPSRVResolver processRecord:length:] in XMPPSRVResolver.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Source: (StackOverflow)

How to get prefrences in XEP-0136: Message Archiving?

My Message Archiving is fine , message is saving in database easily but for some reason i want to fetch the preference set for xep-0136 .

As stated in xep-0136 extension to get preference we need to send this IQ

<iq type="get" id="pref1">
    <pref xmlns="urn:xmpp:archive">
    </pref>
</iq>

But on sending this I am getting error in response that service is unavailable but i dont know how this can be possible ? because message archiving is working all fine. do i need to implement some other module.

error iq

<iq
    xmlns="jabber:client"
    from="ramu_gmail.com@##.##.##.##"
    to="ramu_gmail.com@##.##.##.##/42117879931439208568472324"
    type="error"
    id="pref1">
    <pref xmlns="urn:xmpp:archive"></pref>
    <error code="503" type="cancel">
        <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>
    </error>
</iq>

Guys please suggest.Thanks in advance.


Source: (StackOverflow)

Accepting chatroom invitation

I'm able to create a MUC using XMPPFramework and send user invitation requests to join that room by using the code below.

// Creating
AppDelegate *dele =(AppDelegate *) [[UIApplication sharedApplication]delegate];

xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:dele jid:[XMPPJID jidWithString:self.roomName] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom addDelegate:dele delegateQueue:dispatch_get_main_queue()];
[xmppRoom activate:dele.xmppStream];
[xmppRoom joinRoomUsingNickname:self.myNick history:nil];

// Inviting
[xmppRoom inviteUser:[XMPPJID jidWithString:@"abc@host"] withMessage:@"Come Join me"];

How does a user "abc" know that he has received an invitation and how can he react to it either by accepting or declining?

I could not find any class in XMPPFramework which directly deal with chat room invitation. My research says that whenever a user receives an chatroom invitation, xmmppStream's delegate method is called:

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message

In that message, I check whether the it contains NSXMLElement with name "invite", and if it contains then i send a callback to the user. Then i create chatroom with the same name as the name of the chatroom from which user received invitation and enter that newly created room. It works fine but quiet lengthy and not quiet efficient. I want to know if there is a class in XMPPFramework available here which could handle chat room invitation separately. For instance, detecting, accepting, and declining of room invitations.

My code for extracting room name:

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
{
    NSXMLElement * x = [message elementForName:@"x" xmlns:XMPPMUCUserNamespace];
    NSXMLElement * invite  = [x elementForName:@"invite"];
    NSXMLElement * decline = [x elementForName:@"decline"];
    NSXMLElement * directInvite = [message elementForName:@"x" xmlns:@"jabber:x:conference"];
    NSString *msg = [[message elementForName:@"body"]stringValue];
    NSString *from = [[[message attributeForName:@"from"]stringValue];
    if (invite || directInvite)
    {
        [self createAndEnterRoom:from Message:msg];
        return;
    }
    [self.delegate newMessageRecieved:msg];
}

Source: (StackOverflow)

Trouble creating xmpp muc room: Code 503 (service unavailable)

My code to create a room:

XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"groupchat@xmpp.getkismet.com/groupchat"] dispatchQueue:dispatch_get_main_queue()];

[xmppRoom activate:[[self appDelegate] xmppStream]];
if ([xmppRoom preJoinWithNickname:@"nameToCreateRoom"]) 
{
    NSLog(@"room created");
    [xmppRoom joinRoomUsingNickname:self.userName history:nil];
}
[xmppRoom fetchConfigurationForm];
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom addDelegate:[self appDelegate] delegateQueue:dispatch_get_main_queue()];

Debug:

2012-08-03 07:46:29.204 iPhoneXMPP[9887:fb03] room created
2012-08-03 07:46:29:230 iPhoneXMPP[9887:15003] SEND: <iq type="get" to="groupchat@xmpp.getkismet.com" id="B793062B-0E09-492F-BC0F-703503AAA664"><query xmlns="http://jabber.org/protocol/muc#owner"/></iq>
2012-08-03 07:46:29:237 iPhoneXMPP[9887:15003] SEND: <iq type="set" to="groupchat@xmpp.getkismet.com" id="392D5BFC-707B-4F68-A829-56F949F4E96D"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query></iq>
2012-08-03 07:46:29:326 iPhoneXMPP[9887:14f03] SEND: <presence to="groupchat@xmpp.getkismet.com"><x xmlns="http://jabber.org/protocol/muc"/><x xmlns="vcard-temp:x:update"><photo>91217a961321f8f6380ea2feefd0632353ad296c</photo></x><c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.google.com/p/xmppframework" ver="VyOFcFX6+YNmKssVXSBKGFP0BS4="/></presence>
2012-08-03 07:46:29:327 iPhoneXMPP[9887:14f03] RECV: <iq xmlns="jabber:client" from="groupchat@xmpp.getkismet.com" to="lee@xmpp.getkismet.com/41068195801343976386548353" type="error" id="B793062B-0E09-492F-BC0F-703503AAA664"><query xmlns="http://jabber.org/protocol/muc#owner"/><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
2012-08-03 07:46:29:343 iPhoneXMPP[9887:fb03] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:
2012-08-03 07:46:29:421 iPhoneXMPP[9887:15003] RECV: <iq xmlns="jabber:client" from="groupchat@xmpp.getkismet.com" to="lee@xmpp.getkismet.com/41068195801343976386548353" type="error" id="392D5BFC-707B-4F68-A829-56F949F4E96D"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
2012-08-03 07:46:29:440 iPhoneXMPP[9887:fb03] iPhoneXMPPAppDelegate: xmppStream:didReceiveIQ:

I see that it is creating/joining groupchat@xmpp.getkismet.com and not groupchat@xmpp.getkismet.com/groupchat like I specified. I read that this is most likely the problem. However, I have specified for the full jid, so I'm lost.

Thanks in advance to all who help.


Source: (StackOverflow)

MUC How-to with XMPPFramework

I am developing an iOS XMPP chat app that utilizes Robbie Hanson's XMPPFramework.

The most important functionalities have been implemented - sending and receiving messages. Basically, I've built a basic functional chat app already, with a little eye candy of course.

Now, the problem I have is regarding MUC. The codes I saw from other websites show that there is a method initWithRoomName in XMPPRoom. However, this method is absent in the git repo I cloned. So, what is the alternative to this? Or, if there is none, how do I go about creating rooms using XMPPFramework?

Thanks.


Source: (StackOverflow)

xmppstream delegate methods not getting called on my custom class

I started with xmppframework recently,but i am stuck with an issue.i am able to connect to my server on my local network but the xmppstreamdelegate methods are not getting called on my custom class,but works absolutely fine on appdelegate class .Can anyone pls help me on this.Is the delegate only supported on the appdelegate class ?

Header:

@interface XmppClass : NSObject<XMPPStreamDelegate>{
    XMPPStream *xmppStream;
    Login * loginDetail;
    BOOL allowSelfSignedCertificates;
    BOOL allowSSLHostNameMismatch;
}
@property (nonatomic, strong, readonly) XMPPStream *xmppStream;

@property (nonatomic, strong) Login *loginDetail;
- (id)initWithLogin:(Login *) loginrefernce;
- (BOOL)connect;
- (void)disconnect;
- (void)setupStream;
@end

Implementation:

@implementation XmppClass

@synthesize xmppStream;
@synthesize loginDetail;
- (id)initWithLogin:(Login *) loginrefernce
{
    self = [super init];
    if (self) {
        self.loginDetail=loginrefernce;
        [DDLog addLogger:[DDTTYLogger sharedInstance]];
        [self setupStream];
        [self connect];
    }
    return self;
}
- (void)setupStream
{
NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times");
// Setup xmpp stream
// 
// The XMPPStream is the base class for all activity.
// Everything else plugs into the xmppStream, such as modules/extensions and delegates.

xmppStream = [[XMPPStream alloc] init];
#if !TARGET_IPHONE_SIMULATOR
{
// Want xmpp to run in the background?
// 
// P.S. - The simulator doesn't support backgrounding yet.
//        When you try to set the associated property on the simulator, it simply fails.
//        And when you background an app on the simulator,
//        it just queues network traffic til the app is foregrounded again.
//        We are patiently waiting for a fix from Apple.
//        If you do enableBackgroundingOnSocket on the simulator,
//        you will simply see an error message from the xmpp stack when it fails to set the property.
xmppStream.enableBackgroundingOnSocket = YES;
}
#endif

NSLog(@"setup stream");
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

[xmppStream setHostName:@"10.68.202.123"];
//[xmppStream setHostPort:8070];

allowSelfSignedCertificates = NO;
allowSSLHostNameMismatch = NO;

// You may need to alter these settings depending on the server you're connecting to

}

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


//
// 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 = @"user@gmail.com/xmppframework";
// myPassword = @"";
if (self.loginDetail.emailId == nil || self.loginDetail.password == nil) {
    return NO;
}

[xmppStream setMyJID:[XMPPJID jidWithString:[self.loginDetail.emailId      stringByAppendingString:@"/pc"]]];


NSError *error = nil;
if (![xmppStream connect:&error])
{

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

    return NO;
}

return YES;
}

- (void)disconnect
{
    [xmppStream disconnect];
}
- (void)xmppStream:(XMPPStream *)sender socketDidConnect:(GCDAsyncSocket *)socket 
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}

- (void)xmppStream:(XMPPStream *)sender willSecureWithSettings:(NSMutableDictionary *)settings
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    NSLog(@"some security thing");
    if (allowSelfSignedCertificates)
    {
        [settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString  *)kCFStreamSSLAllowsAnyRoot];
    }
    if (allowSSLHostNameMismatch)
    {
        [settings setObject:[NSNull null] forKey:(NSString *)kCFStreamSSLPeerName];
    }
    else
   {
        // Google does things incorrectly (does not conform to RFC).
        // Because so many people ask questions about this (assume xmpp framework is broken),
        // I've explicitly added code that shows how other xmpp clients "do the right thing"
        // when connecting to a google server (gmail, or google apps for domains).
        NSString *expectedCertName = nil;
        NSString *serverDomain = xmppStream.hostName;
        NSString *virtualDomain = [xmppStream.myJID domain];
        if ([serverDomain isEqualToString:@"talk.google.com"])
        {
             if ([virtualDomain isEqualToString:@"gmail.com"])
             {
                  expectedCertName = virtualDomain;
             }
             else
             {
                  expectedCertName = serverDomain;
             }
        }
        else if (serverDomain == nil)
        {
             expectedCertName = virtualDomain;
        }
        else
        {
             expectedCertName = serverDomain;
        }
        if (expectedCertName)
        {
             [settings setObject:expectedCertName forKey:(NSString *)kCFStreamSSLPeerName];
        }
}

}

- (void)xmppStreamDidSecure:(XMPPStream *)sender
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}

- (void)xmppStreamDidConnect:(XMPPStream *)sender
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    NSLog(@"connected");
    NSError *error = nil;
    if (![[self xmppStream] authenticateWithPassword:self.loginDetail.password error:&error])
    {
            DDLogError(@"Error authenticating: %@", error);
    }
}

- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    NSLog(@"authenticated");

}

- (void)xmppStream:(XMPPStream *)sender didNotAuthenticate:(NSXMLElement *)error
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    NSLog(@"did not authenticate");
}

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    return NO;
}

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

    // A simple example of inbound message handling.

}

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
    DDLogVerbose(@"%@: %@ - %@", THIS_FILE, THIS_METHOD, [presence fromStr]);
}

- (void)xmppStream:(XMPPStream *)sender didReceiveError:(id)error
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
}

- (void)xmppStreamDidDisconnect:(XMPPStream *)sender withError:(NSError *)error
{
    DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
    NSLog(@"%@",error);
}
@end

Source: (StackOverflow)

Send a message via XMPPFramework for iOS

How do I send a message through the XMPPFramework for objc and ios?

Its really bugging me now. I need to build a custom method with some custom XML and send it to a specific JID.

Any ideas?

Thank you.


Source: (StackOverflow)