TasZ
TasZ

Reputation: 167

send friend request to user using xmpp and openfire

hello i have used openfire as a server and want to send friend request for that i am using following code

- (XMPPRoster *)xmppRoster {
    return [[self appDelegate] xmppRoster];
}

-(IBAction)SendFriendRequest:(id)sender
{
    XMPPJID *newBuddy = [XMPPJID jidWithString:@"[email protected]"];

    [[[self appDelegate]xmppRoster]addUser:newBuddy withNickname:@"test user 1"];
}

i am getting this type of log

<iq xmlns="jabber:client" type="error" to="192.168.4.21/de4fd927"><query xmlns="jabber:iq:roster"><item jid="[email protected]" name="test user 3"></item></query><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></not-authorized></error></iq>

i am unable to send request to "test1" has been logged in spark.

Any help would be appreciable!

Upvotes: 3

Views: 2353

Answers (2)

Gaurav Singla
Gaurav Singla

Reputation: 2291

It seem you have not initialised xmppRoster in setupStream method:

Please try to write the following code in setup stream:

xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];

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

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

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

[xmppRoster activate:xmppStream];

Hope it will give some help

Upvotes: 1

vitalyster
vitalyster

Reputation: 5266

  1. Every XMPP entity, which can exchange XMPP packets with other entity, should have JID in [email protected] form, you are trying to use IP address instead of domain name, which is possible, but potentially can give unexpectable errors.

  2. You should be authenticated at server before you able to exchange packets with others.

Upvotes: 1

Related Questions