Class DeliveryReceiptManager


  • public final class DeliveryReceiptManager
    extends org.jivesoftware.smack.Manager
    Manager for XEP-0184: Message Delivery Receipts. This class implements the manager for DeliveryReceipt support, enabling and disabling of automatic DeliveryReceipt transmission.

    You can send delivery receipt requests and listen for incoming delivery receipts as shown in this example:

     deliveryReceiptManager.addReceiptReceivedListener(new ReceiptReceivedListener() {
       void onReceiptReceived(String fromJid, String toJid, String receiptId, Stanza receipt) {
         // If the receiving entity does not support delivery receipts,
         // then the receipt received listener may not get invoked.
       }
     });
     Message message = …
     DeliveryReceiptRequest.addTo(message);
     connection.sendStanza(message);
     
    DeliveryReceiptManager can be configured to automatically add delivery receipt requests to every message with autoAddDeliveryReceiptRequests().
    See Also:
    XEP-0184: Message Delivery Receipts
    • Method Detail

      • setDefaultAutoReceiptMode

        public static void setDefaultAutoReceiptMode​(DeliveryReceiptManager.AutoReceiptMode autoReceiptMode)
        Set the default automatic receipt mode for new connections.
        Parameters:
        autoReceiptMode - the default automatic receipt mode.
      • getInstanceFor

        public static DeliveryReceiptManager getInstanceFor​(org.jivesoftware.smack.XMPPConnection connection)
        Obtain the DeliveryReceiptManager responsible for a connection.
        Parameters:
        connection - the connection object.
        Returns:
        the DeliveryReceiptManager instance for the given connection
      • isSupported

        public boolean isSupported​(org.jxmpp.jid.Jid jid)
                            throws org.jivesoftware.smack.SmackException,
                                   org.jivesoftware.smack.XMPPException,
                                   java.lang.InterruptedException
        Returns true if Delivery Receipts are supported by a given JID.
        Parameters:
        jid - TODO javadoc me please
        Returns:
        true if supported
        Throws:
        org.jivesoftware.smack.SmackException - if there was no response from the server.
        org.jivesoftware.smack.XMPPException - if an XMPP protocol error was received.
        java.lang.InterruptedException - if the calling thread was interrupted.
      • addReceiptReceivedListener

        public void addReceiptReceivedListener​(ReceiptReceivedListener listener)
        Get informed about incoming delivery receipts with a ReceiptReceivedListener.
        Parameters:
        listener - the listener to be informed about new receipts
      • removeReceiptReceivedListener

        public void removeReceiptReceivedListener​(ReceiptReceivedListener listener)
        Stop getting informed about incoming delivery receipts.
        Parameters:
        listener - the listener to be removed
      • autoAddDeliveryReceiptRequests

        public void autoAddDeliveryReceiptRequests()
        Enables automatic requests of delivery receipts for outgoing messages of Message.Type.normal, Message.Type.chat or Message.Type.headline, and with a Message.Body extension.
        Since:
        4.1
        See Also:
        dontAutoAddDeliveryReceiptRequests()
      • dontAutoAddDeliveryReceiptRequests

        public void dontAutoAddDeliveryReceiptRequests()
        Disables automatically requests of delivery receipts for outgoing messages.
        Since:
        4.1
        See Also:
        autoAddDeliveryReceiptRequests()
      • hasDeliveryReceiptRequest

        public static boolean hasDeliveryReceiptRequest​(org.jivesoftware.smack.packet.Message message)
        Test if a message requires a delivery receipt.
        Parameters:
        message - Stanza object to check for a DeliveryReceiptRequest
        Returns:
        true if a delivery receipt was requested
      • addDeliveryReceiptRequest

        @Deprecated
        public static java.lang.String addDeliveryReceiptRequest​(org.jivesoftware.smack.packet.Message m)
        Add a delivery receipt request to an outgoing packet. Only message packets may contain receipt requests as of XEP-0184, therefore only allow Message as the parameter type.
        Parameters:
        m - Message object to add a request to
        Returns:
        the Message ID which will be used as receipt ID
      • receiptMessageFor

        public static org.jivesoftware.smack.packet.Message receiptMessageFor​(org.jivesoftware.smack.packet.Message messageWithReceiptRequest)
        Create and return a new message including a delivery receipt extension for the given message.

        If messageWithReceiptRequest does not have a Stanza ID set, then null will be returned.

        Parameters:
        messageWithReceiptRequest - the given message with a receipt request extension.
        Returns:
        a new message with a receipt or null.
        Since:
        4.1