What version of ejabberd are you using?
ejabberd 17.09
What operating system (version) are you using?
Ubuntu 16.04.3 LTS
How did you install ejabberd (source, package, distribution)?
Package; Downloaded .deb file and installed using dpkg
What did not work as expected? Are there error messages in the log? What
was the unexpected behavior? What was the expected result?
I am trying to use mod_push as it is implemented in XEP-0357. I am able to enable users to get push notifications, however the notifications that are generated by mod_push and passed to the pubsub node do not include any message contents or information.
According to XEP-0357 Section 7:
A data form whose FORM_TYPE is 'urn:xmpp:push:summary' MAY be included to provide summarized information such as the number of unread messages or number of pending subscription requests.
Does ejabberd support this form type with notifications? If so, how do I enable of configure it?
For clarification, below I what I would like the notification iq to look like (taken from XEP-0357, Section 7):
<iq type='set'
from='example.com'
to='push-5.client.example'
id='n12'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='yxs32uqsflafdk3iuqo'>
<item>
<notification xmlns='urn:xmpp:push:0'>
<x xmlns='jabber:x:data'>
<field var='FORM_TYPE'><value>urn:xmpp:push:summary</value></field>
<field var='message-count'><value>1</value></field>
<field var='last-message-sender'><value>[email protected]/balcony</value></field>
<field var='last-message-body'><value>Wherefore art thou, Romeo?</value></field>
</x>
<additional xmlns='http://example.com/custom'>Additional custom elements</additional>
</notification>
</item>
</publish>
</pubsub>
</iq>
And this is what it currently looks like:
<iq type='set'
from='example.com'
to='push-5.client.example'
id='n12'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='yxs32uqsflafdk3iuqo'>
<item>
<notification xmlns='urn:xmpp:push:0'>
</notification>
</item>
</publish>
</pubsub>
</iq>
(The notification item tag is empty)
Does ejabberd support this form type with notifications?
Short answer: no.
As per the XEP, this (optional) feature can't be controlled by the client, and many XMPP users probably don't want message contents to be sent to proprietary push services due to privacy concerns.
Conceptually, the notifications generated by mod_push are meant to work as wake-up events only: The idea is that a notification would trigger the mobile app to reconnect, check for messages, and then (optionally) notify the user itself.
This is somewhat problematic on iOS, where you'd need to use silent notifications to implement things this way, and those aren't guaranteed to be delivered reliably, at least for non-VoIP apps. One workaround is to let the app server generate regular (high-priority) notifications with a generic New Message! body. Some apps do this.
The problem is that the app server can't be sure there actually is a message the user wants to be notified about: If the client's stream management session is still alive, push notifications might be generated for non-message stanzas (e.g., for IQs). This could be addressed by (ab)using the feature you mentioned to communicate the type of stanza to the app server. For this reason, I'm considering to implement it, though I'm still unsure whether to support sending the actual plain-text body when notifying on actual (unencrypted) messages, as opposed to just sending New Message! strings in this case.
Thank you for getting back to me and explaining everything in depth! I see your concerns about privacy- that does seem to be a fairly large issue with xmpp notifications. Especially if the third party service is untrusted in some way (which may be exactly why the xmpp application is being used in the first place).
The counterpoint, though, is that many applications using xmpp for chat mean to use it as a secondary, in-app chat service to facilitate a connection between two otherwise unconnected people. Users concerned about privacy could switch to some other primary, more private, chat service (which may also be implemented through xmpp or other).
Like you mention, there are also other pieces of information that could be valuable for the user to know without spilling the plaintext content of the message. Things like message count and message sender are two examples of these on top of the non-message vs message stanza communication that you mention. Not having control over these settings may be a deal breaker for users hoping to use ejabberd over some other server software.
Ideally, this could be a user specific setting that clients choose while enabling notifications, however, like you say, the documentation does not support this. In my opinion the next best thing would be to allow server administrators to configure mod_push to use none, a subset, or all of these features. In this way, applications whose primary concern is privacy can use the most restricted options while applications whose primary concern is notification could use the most open options.
For the time being, I'll stick with a standard "_New Message!_" notification and possibly look into the old version of mod_push and other server softwares. Thanks again!
many applications using xmpp for chat mean to use it as a secondary, in-app chat service
Indeed, but those are typically commercial use cases who might be better off using the Business Edition with APNS/GCM support built in :-)
Does ejabberd support this form type with notifications? If so, how do I enable of configure it?
With the next ejabberd release, you can tell mod_push to include the last sender and body with notifications:
mod_push:
include_sender: true
include_body: true
Where do I have to mention the URL for push notification ?? I want to push to onesignal for every offline message !! Is there any documentation explaining the process? wilol it send push notification for group messages also?
I want to push to onesignal for every offline message
I don't think mod_push will help you much. I'd suggest building a custom module that does what you want.
Is there any documentation explaining the process?
I have no experience in ejabberd or Erlang. I don't know how to build a module, especially for this use case. Do you know any examples that can help me here. I need to push to onesignal for every offline message either in group or single chat.
You should then consider using the Business Edition.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.