Use push functionality in webbrowsers
Is your feature request related to a problem? Please describe. Most of the people are interested to have a signaling solution if something related to them happens on the portal
Describe the solution you'd like Even if it is possible that it can be built in Chamilo, it also makes sense to have this independent. Like https://gotify.net
Not sure yet we'll do this in Chamilo 2.0. Seems to be very little interest for that so far (as per comments on this issue)
Hello Yannick,
two options: either browser push or app. Otherwise Chamilo will fallback even more behind Moodle. What do you think, why the usage is not that widespread? :-)
Apparently Gotify is a great Open Source push notifications servers (in Go). This could be useful for debugging/testing. Enabling push in Chamilo 2 should ideally let the user define which push notification server to use (although I suppose the mobile app then needs to offer to reconfigure the push notifications servers as well).
It is implemented with this PR https://github.com/chamilo/chamilo-lms/pull/6421
Implemented features
- Users can subscribe/unsubscribe to browser push notifications from their profile.
- Works in Firefox and Chrome, over HTTPS with a valid SSL certificate.
- Chamilo 2 can now send browser push notifications for:
Direct messages Activity alerts Custom notifications
Technical changes
- New database table: push_subscription storing:
endpoint publicKey authToken contentEncoding userAgent user_id relation timestamps
- New platform setting push_notification_settings :
{ "gotify_url": "http://localhost:8080", "gotify_token": "A0yWWfe_8YRLv_B", "enabled": true, "vapid_public_key": "BNg54MTyDZSdyFq99EmppT606jKVDS5o7jGVxMLW3Qir937A98sxtrK4VMt1ddNlK93MUenK0kM3aiAMu9HRcjQ=", "vapid_private_key": "UgS5-xSneOcSyNJVq4c9wmEGaCoE1Y8oh-7ZGXPgs8o" }
- Example backend controller implemented:
/push-notifications/send/{userId} Allows sending a test notification to all registered subscriptions for a user.
/push-notifications/send-gotify Supports sending via web push or Gotify.
- Uses Minishlink/WebPush PHP library for handling Web Push protocol. Requires running: composer install
It requires testing. Thanks for confirmation.
A little rough around the edges (the settings will probably require more detailed documentation somewhere to make it more accessible), but we've seen it work and the code looks good for an alpha 3. It allows the admin to use Chamilo as a push notifications server and to use a remote Gotify instance (or another compatible push server) as alternative if using the local server is/becomes too slow. The final user has to opt in to push notifications from the profile page, and no intrusive request is made to enable it.
The fact that it uses its own icons instead of the theme-based icon of the portal is still an issue.
I wonder if urlBase64ToUint8Array() does not introduce a vulnerability (does it generate something dangerous by changing from base64 to uint8?). To be checked.
Lang vars to be added or modified by myself:
| Term | Used in Vue ? |
|---|---|
| Checking push subscription... | yes |
| You're subscribed to push notifications in this browser. | yes |
| Unsubscribe | yes |
| Endpoint | yes |
| Push notifications are not enabled in this browser. | yes |
| Enable notifications | yes |
| You do not have permission to send notifications to other users. | |
| This user doesn't exist | |
| No push notification setting configured. | |
| VAPID keys are missing in the configuration. | |
| No push subscriptions found for this user. | |
| Push notification test | |
| This is a test push notification from this platform to the user's browser or app. | |
| Push notifications have been processed. | |
| User not found. | |
| Gotify configuration is missing. | |
| This is a test notification sent to Gotify from this platform. | |
| Notification sent to Gotify. | |
| Error sending notification to Gotify: | |
| Push notification settings (JSON) | |
| JSON configuration for Push notifications integration. Example: {'gotify_url':'http://localhost:8080','gotify_token':'yourtoken','enabled':true}. Leave empty if you do not want to use push notifications. |
Icons loading should be fixed by 2a65a94 Text reviewed in ac6adc3
Thanks for the swift integration @christianbeeznest ! 🦾