mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 09:09:38 +02:00
Push Notifications (XEP-0357) implementation
Fixes SMACK-738
This commit is contained in:
parent
1d3c48e6ce
commit
e266b1acd8
14 changed files with 855 additions and 1 deletions
|
@ -86,6 +86,7 @@ Experimental Smack Extensions and currently supported XEPs of smack-experimental
|
|||
| JSON Containers | [XEP-0335](http://xmpp.org/extensions/xep-0335.html) | Encapsulation of JSON data within XMPP Stanzas. |
|
||||
| [Internet of Things - Discovery](iot.md) | [XEP-0347](http://xmpp.org/extensions/xep-0347.html) | Describes how Things can be installed and discovered by their owners. |
|
||||
| Client State Indication | [XEP-0352](http://xmpp.org/extensions/xep-0352.html) | A way for the client to indicate its active/inactive state. |
|
||||
| [Push Notifications](pushnotifications.md) | [XEP-0357](http://xmpp.org/extensions/xep-0357.html) | Defines a way to manage push notifications from an XMPP Server. |
|
||||
| Google GCM JSON payload | n/a | Semantically the same as XEP-0335: JSON Containers |
|
||||
|
||||
|
||||
|
|
82
documentation/extensions/pushnotifications.md
Normal file
82
documentation/extensions/pushnotifications.md
Normal file
|
@ -0,0 +1,82 @@
|
|||
Push Notifications
|
||||
==================
|
||||
|
||||
Allows to manage how XMPP servers deliver information for use in push notifications to mobile and other devices.
|
||||
|
||||
* Check push notifications support
|
||||
* Enable push notifications
|
||||
* Disable push notifications
|
||||
* Remote disabling of push notifications
|
||||
|
||||
|
||||
**XEP related:** [XEP-0357](http://xmpp.org/extensions/xep-0357.html)
|
||||
|
||||
|
||||
Get push notifications manager
|
||||
------------------------------
|
||||
```
|
||||
PushNotificationsManager pushNotificationsManager = PushNotificationsManager.getInstanceFor(connection);
|
||||
```
|
||||
|
||||
|
||||
Check push notifications support
|
||||
--------------------------------
|
||||
|
||||
```
|
||||
boolean isSupported = pushNotificationsManager.isSupportedByServer();
|
||||
```
|
||||
|
||||
|
||||
Enable push notifications
|
||||
-----------------------
|
||||
|
||||
```
|
||||
pushNotificationsManager.enable(pushJid, node);
|
||||
```
|
||||
or
|
||||
```
|
||||
pushNotificationsManager.enable(pushJid, node, publishOptions);
|
||||
```
|
||||
*pushJid* is a `Jid`
|
||||
|
||||
*node* is a `String`
|
||||
|
||||
*publishOptions* is a `HashMap<String, String>` (which means [option name, value])
|
||||
|
||||
|
||||
Disable push notifications
|
||||
--------------------------
|
||||
|
||||
```
|
||||
pushNotificationsManager.disable(pushJid, node);
|
||||
```
|
||||
*pushJid* is a `Jid`
|
||||
|
||||
*node* is a `String`
|
||||
|
||||
**Disable all**
|
||||
|
||||
```
|
||||
pushNotificationsManager.disableAll(pushJid);
|
||||
```
|
||||
*pushJid* is a `Jid`
|
||||
|
||||
|
||||
Remote disabling of push notifications
|
||||
--------------------------------------
|
||||
|
||||
```
|
||||
// check if the message is because remote disabling of push notifications
|
||||
if (message.hasExtension(PushNotificationsElements.RemoteDisablingExtension.ELEMENT, PushNotificationsElements.RemoteDisablingExtension.NAMESPACE)) {
|
||||
|
||||
// Get the remote disabling extension
|
||||
PushNotificationsElements.RemoteDisablingExtension remoteDisablingExtension = PushNotificationsElements.RemoteDisablingExtension.from(message);
|
||||
|
||||
// Get the user Jid
|
||||
Jid userJid = remoteDisablingExtension.getUserJid();
|
||||
|
||||
// Get the node
|
||||
String node = remoteDisablingExtension.getNode();
|
||||
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue