Custom XMPP IQ in iOS XMPP Framework

2019-05-30 05:10发布

问题:

I want to send custom IQ using xmpp framework in iOS for the following XML:

<iq type="get">
<questionrequest xmlns="xyz" group="abc">
</questionrequest>
</iq>

I used the below code in iOS:

XMPPIQ *iq = [[XMPPIQ alloc] initWithType:@"get"];
DDXMLElement *query = [DDXMLElement elementWithName:@"questionrequest" xmlns:@"xyz" group:@"abc"];
[iq addChild:query];
[[[self appDelegate] xmppStream] sendElement:iq];
NSLog(@"iq: %@", [iq prettyXMLString]);

It is giving an error when I add group="abc"> part in DDXMLElement *query. Please help.

回答1:

it worked by using the below code:

XMPPIQ *iq = [[XMPPIQ alloc] initWithType:@"get"];
    DDXMLElement *query = [DDXMLElement elementWithName:@"questionrequest" xmlns:@"naseebprofile"];
    [query addAttributeWithName:@"group" stringValue:@"Tastes"];
    [iq addChild:query];
    [[[self appDelegate] xmppStream] sendElement:iq];