xmpp好友請求5

來源:互聯網
上載者:User

標籤:style   blog   color   io   os   ar   for   strong   sp   

實現好友請求

.m

 1 #pragma mark - rosterHandle 2  3 // initRoster 4 - (void)initRoster { 5     self.xmppRosterMemory = [[XMPPRosterMemoryStorage alloc] init]; 6     self.xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:self.xmppRosterMemory]; 7     [_xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()]; 8     [_xmppRoster activate:self.xmppStream]; 9 }10 11 - (void)addFriend: (NSString *)accountName {12     [_xmppRoster addUser:[XMPPJID jidWithString:[accountName stringByAppendingString:DOMAINS]] withNickname:nil];13 }14 15 - (void)removeFriend: (NSString *)accountName {16     [_xmppRoster removeUser:[XMPPJID jidWithString:[accountName stringByAppendingString:DOMAINS]]];17 }18 19 // call back20 - (void)dealWithFriendAsk: (BOOL)isAgree21               accountName: (NSString *)accountName {22     XMPPJID * jid=[XMPPJID jidWithString:[NSString stringWithFormat:@"%@%@",accountName,DOMAINS]];23     if(isAgree){24         [self.xmppRoster acceptPresenceSubscriptionRequestFrom:jid andAddToRoster:NO];25     }else{26         [self.xmppRoster rejectPresenceSubscriptionRequestFrom:jid];27     }28 29 }30 31 #pragma mark addFriendDelegateMethods32 - (void)xmppRoster:(XMPPRoster *)sender didReceivePresenceSubscriptionRequest:(XMPPPresence *)presence {33     34     NSString *presenceFromUser =[NSString stringWithFormat:@"%@", [[presence from] user]];35     if (self.acceptOrDenyFriend != nil) {36         BOOL isAgree = self.acceptOrDenyFriend(presenceFromUser);37         [self dealWithFriendAsk:isAgree accountName:presenceFromUser];38     }39 }40 41 @end

.h

 1 /*! 2  *  @Author Dylan. 3  * 4  *  addRoster. 5  */ 6 // if you want to deny or add friend. please call this block 7 @property (nonatomic, copy) BOOL (^acceptOrDenyFriend) (NSString *); 8 @property (nonatomic, strong) XMPPRoster * xmppRoster; 9 10 /*!11  *  @Author Dylan. Methods12  */13 - (void)addFriend: (NSString *)accountName;14 - (void)removeFriend: (NSString *)accountName;

 

xmpp好友請求5

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.