我正在创建一个可以在 iOS 和 Android 平台上运行的聊天应用程序。有时两端都没有收到“两者”订阅。谁能告诉我可能是什么问题?
===================== 对于 iOS =====================
发送请求,
XMPPJID *XMPPJIDObj=[XMPPJID jidWithString:aStrOtherJabberId];
[appDelegateObj.xmppRoster addUser:XMPPJIDObj withNickname:nil];
接受请求,
[appDelegateObj.xmppRoster acceptPresenceSubscriptionRequestFrom:aReceiverJID andAddToRoster:TRUE];
删除用户,
[appDelegateObj.xmppRoster removeUser:[XMPPJID jidWithString:aPresenceObj.userJabberID]];
====================== 对于Android =====================
发送请求,
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
myApp.getXmppConnection().getRoster().createEntry(visitorJabberId, visitorUserName, null);
接受请求,
final Presence presence1 = new Presence(Type.subscribed);
presence1.setFrom(myApp.getUserJabberId());
presence1.setType(Type.subscribed);
presence1.setTo(visitorJabberId);
myApp.getXmppConnection().sendPacket(presence1);
myApp.getXmppConnection().getRoster().createEntry(visitorJabberId, visitorUserName, null);
删除用户,
final RosterPacket rosterPacket = new RosterPacket();
rosterPacket.setType(IQ.Type.SET);
final RosterPacket.Item item = new RosterPacket.Item(visitorJabberId, null);
item.setItemType(RosterPacket.ItemType.remove);
rosterPacket.addRosterItem(item);
myApp.getXmppConnection().sendPacket(rosterPacket);