Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
Nextcloud Notify Push
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Trujillo
Nextcloud Notify Push
Commits
f202e043
Commit
f202e043
authored
3 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
add notes about js client and custom events to dev docs
Signed-off-by:
Robin Appelman
<
robin@icewind.nl
>
parent
bd561c0e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DEVELOPING.md
+33
-3
33 additions, 3 deletions
DEVELOPING.md
README.md
+7
-1
7 additions, 1 deletion
README.md
with
40 additions
and
4 deletions
DEVELOPING.md
+
33
−
3
View file @
f202e043
...
...
@@ -9,6 +9,18 @@ If you want to listen to incoming events from the web interface of your Nextclou
you can use the
[
`@nextcloud/notify_push`
](
https://www.npmjs.com/package/@nextcloud/notify_push
)
javascript library.
Which will handle all the details for authenticating and connecting to the push server.
```
js
import
{
listen
}
from
'
@nextcloud/notify_push
'
let
has_push
=
listen
(
'
notify_file
'
,
()
=>
{
console
.
log
(
"
A file has been changed
"
)
})
if
(
!
hash_push
)
{
console
.
log
(
"
notify_push not available on the server
"
)
}
```
## Clients
Desktop and other clients that don't run in the Nextcloud web interface can use the following steps to receive notifications.
...
...
@@ -65,11 +77,29 @@ discover_endpoint(nextcloud_url, username, password).then((endpoint) => {
```
```
bash
test_client https://cloud.example.com username password
## Sending custom events
You can send custom events from a nextcloud app using the methods provided by
`OCA\NotifyPush\IQueue`
.
```
php
// in a real app, you'll want to setup DI to get an instance of `IQueue`
$queue
=
\OC
::
$server
->
get
(
OCA\NotifyPush\IQueue
::
class
);
$queue
->
push
(
'notify_custom'
,
[
'user'
=>
"uid"
,
'message'
=>
"my_message_type"
,
'body'
=>
[
"foo"
=>
"bar"
],
// optional
]);
```
Note that this does not support two-factor authentication of non-default login flows, you can use an app-password in those cases.
Which will be pushed to client as
`'my_message_type {"foo": "bar"}'`
and can be used with the
`@nextcloud/notify_push`
client using
```
js
import
{
listen
}
from
'
@nextcloud/notify_push
'
listen
(
'
my_message_type
'
,
(
message_type
,
optional_body
)
=>
{
})
```
## Building
...
...
This diff is collapsed.
Click to expand it.
README.md
+
7
−
1
View file @
f202e043
...
...
@@ -302,4 +302,10 @@ For information about how to use the push server in your own app or client, see
For development and testing purposes a test client is provided which can be downloaded from
the
[
github actions
](
https://github.com/nextcloud/notify_push/actions/workflows/rust.yml
)
page.
<br>
(Click on a run from the list, scroll to the bottom and click on
`test_client`
to download the binary.)
<br>
Please note: the Test client is only build for x86_64 Linux currently.
\ No newline at end of file
Please note: the Test client is only build for x86_64 Linux currently.
```
bash
test_client https://cloud.example.com username password
```
Note that this does not support two-factor authentication of non-default login flows, you can use an app-password in those cases.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment