How to get the message delivary status using XMPP framework

前端 未结 1 704
耶瑟儿~
耶瑟儿~ 2020-12-13 11:44

I am using the XMPP Framework for chatting between the users , Chatting is happening perfectly .Now I need to show the message is delivered perfectly to both devices like (W

相关标签:
1条回答
  • 2020-12-13 11:54

    @Romance you need to add below code in the connect method

      XMPPMessageDeliveryReceipts* xmppMessageDeliveryRecipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()];
        xmppMessageDeliveryRecipts.autoSendMessageDeliveryReceipts = YES;
        xmppMessageDeliveryRecipts.autoSendMessageDeliveryRequests = YES;
        [xmppMessageDeliveryRecipts activate:self.xmppStream];
    

    Remember to add these line while sending message

    NSString *messageID=[self.xmppStream generateUUID];
    
            NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
            [message addAttributeWithName:@"id" stringValue:messageID];
            [message addAttributeWithName:@"type" stringValue:@"chat"];
            [message addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"senderJabberID_Here"]];
    
            [message addChild:body];
    

    Hope this help you :)

    0 讨论(0)
提交回复
热议问题