Ich möchte eine Verbindung zu Openfire-Server anonym mit XMPP-Framework in iOS. Ich kann eine Verbindung zum offenen Feuer herstellen, indem ich JID und PW zur Verfügung stelle. Wenn ich jedoch anonym eine Verbindung herstellen wollte, heißt es "Der Server unterstützt keine anonyme Authentifizierung".anonymisieren mit XMPP-Framework in iOS
Ich verwende eine Schaltfläche in XIB-Datei. Wenn sein Code unten geklickt ausführt:
- (IBAction)login:(id)sender {
[[self appDelegate]connect];
NSError *authenticationError = nil;
[self.xmppStream authenticateAnonymously:&authenticationError];
}
und unten ist der Code für Connect-Methode:
- (BOOL)connect {
[self setupStream];
xmppStream.hostName = @"abc.xyz.com";
//xmppStream.hostName = @"Virtuals-MacBook-Pro.local ";
NSString *jabberID = [[NSUserDefaults standardUserDefaults] stringForKey:@"userID"];
NSString *myPassword = [[NSUserDefaults standardUserDefaults] stringForKey:@"userPassword"];
if (![xmppStream isDisconnected]) {
return YES;
}
if (jabberID == nil || myPassword == nil) {
return NO;
}
[xmppStream setMyJID:[XMPPJID jidWithString:jabberID]];
password = myPassword;
NSError *error = nil;
if (![xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
//[alertView release];
return NO;
}
return YES;
}