我在mycchat应用程序中使用openfire
和xmpp
框架。我正在使用
XMPPJID *newBuddy = [XMPPJID jidWithString:@"test@localhost"];
[self.xmppRoster addUser:newBuddy withNickname:@"user1"];
用于添加新成员但新成员未添加到server
。
在setupStream方法代码中:
xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init];
xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];
xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];
xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage
dispatchQueue:dispatch_get_main_queue()];
[xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
xmppRoster.autoFetchRoster = YES;
xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;
如何添加会员?
答案 0 :(得分:1)
@property (nonatomic, readonly) XMPPStream *xmppStream;
@property (nonatomic, readonly) XMPPRoster *xmppRoster;
@property (nonatomic, readonly) XMPPRosterMemoryStorage *xmppRosterStorage;
在setupStream
方法设置中XMPPStream
和XMPPRoaster
_xmppStream = [[XMPPStream alloc]init];
_xmppStream.enableBackgroundingOnSocket = YES;
_xmppRosterStorage = [[XMPPRosterMemoryStorage alloc] init];
_xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:_xmppRosterStorage];
[_xmppRoster activate:_xmppStream];
[_xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
添加新的contact
[_xmppRoster addUser:jid withNickname:nickName];
接收方接受后,新联系人将反映在您的烘焙列表中