[solved]Sending (push) notifications via OCS

Dear Guys,

i read a little about the open collaboration service (OCS) API but i’m not sure if i understand i right or not.

i’m interested in notifications. Is there a way to send (push) notifications to a user or group via this API? I would like to use my nextcloud as a push-Server for other Services (like Home automation).
With OCC it is possible with

php occ notification:generate username "This is a message"

Actually i want to call this from another system (another docker-Container).

Can someone help me doing this?

Regards,
Stephan

okay i figured it out myself.
it can be done with “admin notification” app and OCS API.

curl -H "OCS-APIREQUEST: true" -u <admin>:<admin-PW> -X POST <https://<my-cloud-address.de>/ocs/v2.php/apps/admin_notifications/api/v1/notifications/<user-to-send-message-to> -d "shortMessage=<message>"

Hi @balli1187
Do you know the OCS requet to sent a push notification for the Android/IOS app?

Hi @arkhej,
It is the curl-request in my former post.
This sends message to the specified user. In my case I get notifications on Android, ios and even Windows if client app has permissions.

Hi!
I lost something in the process because I could create the notification using curl-request but I didn’t get any ‘popup’ on Android…

in version Nextcloud 22.1.X, the following worked for me:


curl -H "OCS-APIREQUEST: true" -X POST \
	https://<AdminID:AdminAppPassword>@<SERVER>/ocs/v2.php/apps/notifications/api/v2/admin_notifications/<user> \
	-d shortMessage="Short Message" \
	-d longMessage="This is the long message"

@OneTime
Thanks alot for sharing this.
I changed my implementation to this and works perfectly.