androidxmppsmack

XMPPError: subscription-required - auth


Making Chat App using Smack , Try to get the Last Seen time of user but getting following Exception

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: subscription-required - auth

Code :

  public void getLastSeen(String JID) {


        LastActivityManager mLastActivity = LastActivityManager.getInstanceFor (connection);
        try {
            try {
                mLastActivity.getLastActivity (JID);
                Log.e (TAG, "" + mLastActivity.getLastActivity (JID));


            } catch (SmackException.NoResponseException e) {
                e.printStackTrace ( );
            }

        } catch (XMPPException.XMPPErrorException e) {
            e.printStackTrace ( );
        } catch (SmackException.NotConnectedException e) {
            e.printStackTrace ( );
        }

    }

getting above Exception on following line

  mLastActivity.getLastActivity (JID);

Anybody know why getting this exception ?


Solution

  • Likely because you need to be subscribed to the contact's presence in order to retrieve the last activity.