我正在开发基于聊天的应用程序并使用xmpp和我的openfire服务器,我想在ios中添加更改密码功能。我已经搜索了很多fopr更改密码功能(xmpp)并添加了一个更改密码的方法xmpp,但未能这样做。我不知道也没有任何想法,请帮帮我,我的密码修改密码如下:
- (void)goOnline
{
if (appDelegate.signInORnot == 1)
{
self.connectionStatus = OTRProtocolConnectionStatusConnected;
NSLog(@"Account totaltrip..%@",account.totalTrip);
[[NSNotificationCenter defaultCenter] postNotificationName:kOTRProtocolLoginSuccess object:self userInfo:[NSDictionary dictionaryWithObject:account.totalTrip forKey:TOTAL_TRIP_KEY]];
XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit
//Develop By Payal Done
[[self xmppStream] sendElement:presence];
[self changePassword];
}
-(BOOL)changePassword
{
NSUserDefaults *standardUserDefaults = USERDEFAULT;
NSString *passNew = nil;
if (standardUserDefaults)
passNew = [standardUserDefaults objectForKey:@"Newpwd"];
NSUserDefaults *standardUserDefaults1 = USERDEFAULT;
NSString *emailStr = nil;
if (standardUserDefaults1)
emailStr = [standardUserDefaults1 objectForKey:@"mailId"];
NSUserDefaults *standardUserDefaults2 = USERDEFAULT;
NSString *ID = nil;
if (standardUserDefaults2)
ID = [standardUserDefaults2 objectForKey:@"intglCode"];
ID = [ID stringByAppendingString:@"@openfire.netcluesdemo.com"];
NSLog(@"===passed JID===%@",ID);
//NSString *myPassword = passNew;
if (![_xmppStream isDisconnected]) {
return YES;
}
// NSString *myJID = [USERDEFAULT stringForKey: USERNAME];
// NSString *myPassword = [USERDEFAULT stringForKey: PASSWORD];
//CHANGE JIGAR
NSString *myJID=ID;
NSString *myPassword=passNew;
if (myJID == nil || myPassword == nil) {
return NO;
}
[_xmppStream setMyJID:[XMPPJID jidWithString:myJID]];
account.password = myPassword;
// _xmppRegistration = [[XMPPRegistration alloc] init];
// if([OTRXMPPManager changePassword:myPassword])
// {
// return YES;
// }
return NO;
}
答案 0 :(得分:1)
使用以下changePassword:
功能从openfire帐户更改用户密码:
-(void)changePassword:(NSString *)newPassword {
NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"jabber:iq:register"];
NSXMLElement *username = [NSXMLElement elementWithName:@"username"
stringValue:[self xmppStream].myJID.user];
NSXMLElement *password = [NSXMLElement elementWithName:@"password"
stringValue:newPassword];
[query addChild:username];
[query addChild:password];
NSXMLElement *iq = [NSXMLElement elementWithName:@"iq"];
[iq addAttributeWithName:@"type" stringValue:@"set"];
[iq addAttributeWithName:@"id" stringValue:[[self xmppStream] generateUUID]];
[iq addChild:query];
[[self xmppStream] sendElement:iq];
}
在此功能中,在参数中传递新密码。