I have to pass location using XMPP. How can I do it?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As I am give you suggestion regarding single chat. as you are prepare xml formate for sending message in XMPP
as like bellowed.
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:textvalue];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
[message addChild:body];
[[self xmppStream] sendElement:message];
Here add two extra attribute for latitude
and longitude
as like below.
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:textvalue];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:[jid full]];
[message addAttributeWithName:@"latitude" stringValue:@"22.2345"];
[message addAttributeWithName:@"longitude" stringValue:@"42.2345"];
[message addChild:body];
[[self xmppStream] sendElement:message];
there won't be any problem in sending message while adding two extra parameter. and at other end while received this message you can fetched latitude
and longitude
from message and used it as per your requirements.
Hope this help you.