[英]How to pass location using XMPP in ios sdk?
我必須使用XMPP傳遞位置。 我該怎么做?
我給你關於單聊的建議。 因為你准備xml formate用於在XMPP
發送消息,就像吼叫一樣。
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];
這里為latitude
和longitude
添加兩個額外的屬性,如下所示。
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];
添加兩個額外參數時發送消息不會有任何問題。 在收到此消息時,您可以從消息中獲取latitude
和longitude
,並根據您的要求使用它。
希望這對你有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.