简体   繁体   English

如何使用XMPP框架(iphone)将聊天请求(订阅)发送到Openfire服务器上的号码并填充名单?

[英]How to send chat request (subscribe) to number on Openfire server using XMPP framework (iphone) and populate the roster?

I am letting people register to my App using their mobile numbers. 我让人们使用他们的手机号码注册到我的应用程序。 I can see the people online on the admin panel. 我可以在管理面板上在线查看相关人员。 But unless I manually go and add them to the roster and subscribe, they can't chat with each other. 但是除非我手动去将它们添加到花名册中并进行订阅,否则它们将无法彼此聊天。 How can I do this without having to manually add them? 我如何做到这一点而不必手动添加它们?

Install and configure Openfire's Subscription Plugin . 安装和配置Openfire的订阅插件

From the Readme of the Plugin : 插件自述文件

This plugin can be configuured to automatically accept or reject subscription requests. 可以将该插件配置为自动接受或拒绝订阅请求。 When set to accept subscription requests users will be able to add someone to their roster (aka "Buddy List" or "Contacts") without having to wait for a manual subscription acceptance from the requested user. 设置为接受订阅请求后,用户将能够将某人添加到其名册(又名“好友列表”或“联系人”)中,而不必等待被请求用户手动订阅。

To send friend request : 发送朋友请求:

 XMPPJID *newBuddy = [XMPPJID jidWithString:@"Buddyname"];
 [xmppRoster addUser:newBuddy withNickname:nil];

Accept Request: 接受请求:

 - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence{

    if  ([presenceType isEqualToString:@"subscribe"]) {

        [xmppRoster acceptPresenceSubscriptionRequestFrom:presence.from andAddToRoster:YES];
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM