0
votes

I have gone through the XEP 0184 and have done following implementation.

  1. If XMPP is connected and packet then is send then i set the status for each message as SENT (✔︎) if I don't get following callback.

    -(void)xmppStream:(XMPPStream *)sender didReceiveError:(id)error
    
  2. If i get the received status from XEP 0184 implemented in Objective C, I set the status as Delivered (✔︎✔︎)

RECV: < message xmlns="jabber:client" from="[email protected]/2323" to="[email protected]/2223" lang="" >< received xmlns="urn:xmpp:receipts" id="avv-33343"/ >< /message >

  1. But my question is how to show the SEEN status for each message as readh XMPP 0079 that is Advanced Messaging protocol is doing this. But I could not find in Objective C.

Can anyone please help? If my direction is correct and I am missing something could you let me know?

A code snippet guidance would be much appreciated.

Here is my implementation.

Using the stack documentation help I have added the following lines to get the delivery receipts.

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

Now due to this I get the following response for the send and RECV xml.

SEND: 111111111 for avv-33343 Id message. RECV: < message xmlns="jabber:client" from="[email protected]/2323" to="[email protected]/2223" lang="" >< received xmlns="urn:xmpp:receipts" id="avv-33343"/ >< /message >

But this is just giving me info that the message is delivered but how to send the SEEN receipts like above to intimate the sender that the other end user have acknowledged + SEEN the message.

Something like this ... RECV: < seen xmlns="urn:xmpp:receipts" id="222-4444"/ >

1
Could you share what you have tried please? Also, add a tag for the language to help with filtering so more people can view your question - ios, objective-c to name a few.App Dev Guy
In DidConnect I have used XMPPMessageDeliveryReceipts* xmppMessageDeliveryReceipts = [[XMPPMessageDeliveryReceipts alloc] initWithDispatchQueue:dispatch_get_main_queue()]; xmppMessageDeliveryReceipts.autoSendMessageDeliveryReceipts = YES; xmppMessageDeliveryReceipts.autoSendMessageDeliveryRequests = YES; [xmppMessageDeliveryReceipts activate:self.xmppStream]; This gives me <received> node for every message, but how to show seen. What XEP I have to use or XML to send when the user comes in ViewDidAppear of that screen.Vicky Dhas
I have tried XEP 0333 and 022 but as replied by Robinson framework guys this is deprecated and hence is there any alternative way to implement in iOS Like whats app one , two tick and two ticks with blue for seen.Vicky Dhas

1 Answers

0
votes

For seen status use same functionality as send a normal message with same id which message received and you want to mark seen on Sender device, When on sender device receive a static message @"to@fromSeen" with same message id for sent/delivered message, When receiver get exist msg id already in db then your purpose resolve .

Code for send seen status

NSString *bodymessageString = [NSString stringWithFormat:@"to@fromSeen"];
        NSString *str_loginUser = [NSString stringWithFormat:@"%@@%@", [[NSUserDefaults standardUserDefaults]valueForKey:@"mobile"],kXMPPServer ];
        NSString *str_OtherUser = [NSString stringWithFormat:@"%@@%@",str_OtherUserRegName,kXMPPServer];


        NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
        [body setStringValue:bodymessageString];

        NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
        [message addAttributeWithName:@"type" stringValue:@"chat"];
        [message addAttributeWithName:@"from" stringValue:str_loginUser];
        //                    [[[delegate xmppStream] myJID] bare]
        [message addAttributeWithName:@"to" stringValue:str_OtherUser];

        //          NSString *messageID= [XMPPStream generateUUID];
        [message addAttributeWithName:@"id" stringValue:str_msgID];

        //            NSXMLElement *request = [NSXMLElement elementWithName:@"request" xmlns:@"urn:xmpp:receipts"];
        //            [message addChild:request];
        [message addChild:body];

        [[delegate xmppStream] sendElement:message];

        [ChatData GetUpdateToDatabase:str_msgID :@"Seen"];

Code for check message status in appdelegate file

if ([message isChatMessageWithBody])
{
if ([msg isEqualToString:@"to@fromSeen"])
{
   BOOL is_Exist;
   is_Exist = [ChatData  GetAllReadyAvailable :message.elementID];
   if (is_Exist == YES)
   {
     NSString *str_status = [ChatData getstatusChatBy:message.elementID];
     if (![str_status isEqualToString:@"Seen"])
     {
        [ChatData GetUpdateToDatabase:message.elementID :@"Seen"];
     }
   }
 }
 else
 {
   BOOL is_Exist;
  is_Exist = [ChatData  GetAllReadyAvailable :message.elementID];
            if (is_Exist == NO)
            {
              // Store message in DB
            }
  }
}
else if ([message hasReceiptResponse])
{
}
else if([message isErrorMessage])
{}