IOS使用XMPP最新教程(五)添加好友和接受好友请求
来源:互联网 发布:个人域名需要备案吗 编辑:程序博客网 时间:2024/04/30 13:45
加好友要使用Roster类,整个加好友的过程比较简单,就是下面的代码。
XMPPRoster * xmppRoster = [self xmppRoster];
[xmppRoster subscribePresenceToUser:jid];
注意jid是这样生成的:
XMPPJID *jid = [XMPPJID jidWithString:@"3@127.0.0.1"];
然后系统会回调这个函数
- (void)didReceivePresenceSubscriptionRequest:(XMPPPresence *)presence
但是经常会发现这个函数并不执行,解决办法情看我的另一篇帖子XMPP didReceivePresenceSubscriptionRequest函数不执行解决办法
presence里面包含了请求的各种信息
@interface XMPPPresence : XMPPElement
// Converts an NSXMLElement to an XMPPPresence element in place (no memory allocations or copying)
+ (XMPPPresence *)presenceFromElement:(NSXMLElement *)element;
+ (XMPPPresence *)presence;
+ (XMPPPresence *)presenceWithType:(NSString *)type;
+ (XMPPPresence *)presenceWithType:(NSString *)type to:(XMPPJID *)to;
- (id)init;
- (id)initWithType:(NSString *)type;
- (id)initWithType:(NSString *)type to:(XMPPJID *)to;
- (NSString *)type;
- (NSString *)show;
- (NSString *)status;
- (int)priority;
- (int)intShow;
- (BOOL)isErrorPresence;
@end
通过源码可以看到它是继承自XMPPElement的,所以取信息的方法一样。
然后就是接受请求的函数:
[xmppRoster acceptPresenceSubscriptionRequestFrom:jid andAddToRoster:YES];//YES是向对方发送好友请求
拒绝的函数:[xmppRoster rejectPresenceSubscriptionRequestFrom:jid];
- IOS使用XMPP最新教程(五)添加好友和接受好友请求
- IOS使用XMPP最新教程(三)获取好友列表 (通过获取好友状态)
- xmpp-iOS-添加好友和删除好友
- ios,xmpp 添加好友与好友请求处理
- XMPP学习记录五:添加好友和删除好友
- IOS使用XMPP最新教程(四)获取好友列表 (通过花名册)
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- XMPP iOS客户端 添加好友 (3)
- xmpp 添加用户 添加好友请求 删除好友
- XMPPFrameWork IOS 开发(五)获取好友信息和添加删除好友
- XMPPFrameWork IOS 开发(五)获取好友信息和添加删除好友
- [置顶] XMPPFrameWork IOS 开发(五)获取好友信息和添加删除好友
- 修改表空间尺寸
- ios项目重命名
- 用SQL批量替换数据库字符串-PHPCMS
- installshield 2013安装包图标问题
- android studio增量包升级
- IOS使用XMPP最新教程(五)添加好友和接受好友请求
- 配置oracle闪回数据库
- Xcode7开发下 UITableView 在group模式下面 顶部空白的问题和解决
- __attribute__((visibility("default")))
- 日报2015/10/12(极客学院安卓视频学习)
- Image quote
- IO(二、异常处理)
- 位运算技巧
- opencv学习笔记(十一)——图像的载入,显示和输出到文件