如何在ios sdk中使用XMPP传递位置? [英] How to pass location using XMPP in ios sdk?

查看:93
本文介绍了如何在ios sdk中使用XMPP传递位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用XMPP传递位置。我怎么能这样做?

I have to pass location using XMPP. How can I do it?

推荐答案

我给你关于单聊的建议。因为你准备xml格式用于在 XMPP 中发送消息,就像吼叫一样。

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.

希望这对你有帮助。

这篇关于如何在ios sdk中使用XMPP传递位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆