Xmpp chat invisible presence

不想你离开。 提交于 2019-12-04 19:44:43

See XEP-0126: Invisibility, section 3.1:

<iq from='bilbo@tolkien.lit/shire' type='set' id='inv1'>
  <query xmlns='jabber:iq:privacy'>
    <list name='invisible'>
      <item action='deny' order='1'>
        <presence-out/>
      </item>
    </list>
  </query>
</iq>

Have a look at the rfc. Presence has a subscription status. If your bot is subscribed to receive presence from your users but your users are not, they are not going to be notified of the bot's presence.

In other words, your bot should send:

<presence to="user@example.com" type="subscribe" />

followed by the user's authorization,

<presence to="bot@example.com" type="subscribed" />

Now the bot will receive presence from the user, but not the opposite.

To set status for become invisible, you must send a presence with type "invisible".

<presence type="invisible"/>

And here is the code (in ios):

XMPPPresence *presence = [XMPPPresence presenceWithType:@"invisible"];
[[self xmppStream] sendElement:presence];

I use this code to set my status as "invisible". For more details, please read the documentation on http://xmpp.org/extensions/xep-0018.html#sect-id86210

Last I knew from Facebook, it's not possible to implement invisibility via XMPP commands: https://developers.facebook.com/bugs/315067461919373. See also https://developers.facebook.com/docs/chat/ under Limitations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!