原始地址:XMPPFrameWork IOS 開發(七)消息回執html
請參考:XEP-0184協議 app
協議內容:oop
發送消息時附加回執請求測試
- <message
- from='northumberland@shakespeare.lit/westminster'
- id='richard2-4.1.247'
- to='kingrichard@royalty.england.lit/throne'>
- <body>My lord, dispatch; read o'er these articles.</body>
- <request xmlns='urn:xmpp:receipts'/>
- </message>
代碼實現spa
- NSString *siID = [XMPPStream generateUUID];
-
- XMPPMessage *message = [XMPPMessage messageWithType:@"chat" to:jid elementID:siID];
- NSXMLElement *receipt = [NSXMLElement elementWithName:@"request" xmlns:@"urn:xmpp:receipts"];
- [message addChild:receipt];
- [message addBody:@"測試"];
- [self.xmppStream sendElement:message];
收到回執請求的消息,發送回執.net
- <message
- from='kingrichard@royalty.england.lit/throne'
- id='bi29sg183b4v'
- to='northumberland@shakespeare.lit/westminster'>
- <received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>
- </message>
代碼實現xml
- - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
- {
-
- NSXMLElement *request = [message elementForName:@"request"];
- if (request)
- {
- if ([request.xmlns isEqualToString:@"urn:xmpp:receipts"])
- {
-
- XMPPMessage *msg = [XMPPMessage messageWithType:[message attributeStringValueForName:@"type"] to:message.from elementID:[message attributeStringValueForName:@"id"]];
- NSXMLElement *recieved = [NSXMLElement elementWithName:@"received" xmlns:@"urn:xmpp:receipts"];
- [msg addChild:recieved];
-
-
- [self.xmppStream sendElement:msg];
- }
- }else
- {
- NSXMLElement *received = [message elementForName:@"received"];
- if (received)
- {
- if ([received.xmlns isEqualToString:@"urn:xmpp:receipts"])
- {
-
- NSLog(@"message send success!");
- }
- }
- }
-
-
-
- }