我正在尝试使用Xmpp.i创建一个登录页面(emailid,密码,主机名(talk.google.com))。这是我创建的第一页。按下登录按钮后(如果成功,我们将进入进入下一个视图)然后我们将得到另一个视图,它包含两个文本视图,一个用于emailid(我们将为其发送消息),另一个用于消息(发送消息)并通过单击发送按钮我必须发送消息..主要问题对我来说是成功的我得到了记录,但在我无法发送消息到该邮件ID ..可以任何人帮我做这个任务,代码是你好
谢谢你 吉里什-(IBAction)SendButtonPressed:(id)sender
{
NSLog(@"send button clicked");
[self.msgTextView resignFirstResponder];
//NSString *user;
//user=emialTextField.text;
//[self.emialTextField resignFirstResponder];
//XMPPUserCoreDataStorage *user = [(XMPPUserCoreDataStorage *) emialTextField.text];
XMPPJID *jid=[XMPPJID jidWithString:emialTextField.text];
[[self xmppStream] setMyJID:jid];
XMPPApplicationAppDelegate *appDelegate=(XMPPApplicationAppDelegate *)[[UIApplication sharedApplication] delegate];
xmppStream=[appDelegate xmppStream];
//self.user.displayName;
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:self.msgTextView.text];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
//[message addAttributeWithName:@"to" stringValue:[user jid]];
[message addAttributeWithName:@"to" stringValue:self.emialTextField.text];
[message addChild:body];
[xmppStream sendElement:message];
}
答案 0 :(得分:0)
下面,
使用此代码将邮件发送到您域中的任何JID。
- (void)sendMessage:(NSString *)userId
{
NSString *messageStr = @"Hello...";
if([messageStr length] > 0)
{
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:messageStr];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:userId];
[message addChild:body];
[[self xmppStream] sendElement:message];
}
}