- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
DDLogVerbose(@"%@: %@ - %@", THIS_FILE, THIS_METHOD, [presence fromStr]);
NSString *presenceType = [presence type]; // online/offline
NSString *myUsername = [[sender myJID] user];
NSString *presenceFromUser = [[presence from] user];
//
//new request from unknow user
if (![presenceFromUser isEqualToString:myUsername])
{
if ([presenceType isEqualToString:@"subscribe"])
{
//[_chatDelegate newBuddyOnline:[NSString stringWithFormat:@"%@@%@", presenceFromUser, kHostName]];
NSLog(@"presence user wants to subscribe %@",presenceFromUser);
tempPresence = [[XMPPPresence alloc] init];
tempPresence = presence;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New request From:" message:presenceFromUser delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[alert show];
}
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//accept request
if(buttonIndex==1){
[xmppRoster subscribePresenceToUser:[tempPresence from]];
}
}