Vinay1
September 24, 2024, 4:40pm
1
How can we send notifications to the users in the app and also can we send notifications when a new record is created for specific doctypes or workflow states
I am using HR PWA app, how to configure push notifcations for the PWA App
avc
September 24, 2024, 4:46pm
2
Hi @Vinay1 :
As far I know, push notifications need Firecloud integration and I think this is still only avaliable for Frappe Cloud, because it’s needed some kind of relay server.
https://frappehr.com/docs/v14/en/push-notifications
frappe:develop
← tanmoysrt:integrate_frappe_notification
opened 07:26AM - 04 Jan 24 UTC
This PR is to add **Frappe Push Notification Client** in Frappe Framework.
**… Push Notification Client** is a library to communicate with [**Frappe Push Notification Relay Server**](https://github.com/frappe/notification_relay) to manage users, topics and send notifications.
### Changes -
- Added **Push Notification Client** in the Framework.
- Added **Push Notification Settings** doctype to hold some notification settings. The doctype has these parameters
- `api_key` & `api_secret` to send authorized request to **Frappe Push Notification Relay Server**
- `enable push notification relay` checkbox to disable/enable push notification accross the site
### Documentation -
**Configure Push Notification Relay Server**
User can configure relay server endpoint by adding `push_relay_server_url` in `site config`
**Enable Push Notification System**
User can visit `Push Notification Settings` from desk to enable/disable push notification across the site.
**Features -**
- Add/Remove Notification (FCM) Token of end-user
- Create/Delete Notification Topic
- Subscribe/Unsubscribe a end-user to/from a notification topic
- Send notification to end-user
- Send notification to a notification topic
**Available Methods -**
- `constructor(project_name)`: To use PushNotification, create an object and provide the project_name during its creation to set it for the current instance.
```python
from frappe.push_notification import PushNotification
push_notification = PushNotification("hrms")
```
- `is_enabled() -> bool`: This function checks whether the push notification relay is enabled or not for curent site.
- `add_token(user_id, token)`: This function register the FCM notification token for a particular user of current site in relay server
- `remove_token(user_id, token)`: This function removes a specific token of a user from relay server.
- `add_topic(topic_name)`: This function helps to add a new notification topic.
- `remove_topic(topic_name)`: This function removes a notification topic from relay server.
- `subscribe_topic(user_id, topic_name)`: This function subscribes a user to a particular notification topic.
- `unsubscribe_topic(user_id, topic_name)`: This function unsubscribes a user from a particular notification topic.
- `send_notification_to_user(user_id, title, content, link, body, truncate_content)`: This function sends a notification to a user.
- title : Notification title
- content: Notication content
- link: Action link, If provided, on tapping the notification that particular url will be opened
- truncate_body: Notification content has a limitation of 1000 characters, If `truncate_body` enabled, it will auto truncate content if exceeds 1000 characters.
- `send_notification_to_topic(topic_name: str, title: str, content: str, link: str = None, body=None, truncate_body: bool = False) -> bool`: This function sends a notification to a topic and returns a boolean indicating the success status.
**API Endpoints -**
- `/api/method/frappe.push_notification.auth_webhook` : This endpoint is for webhook call which will be invoked by the push notification relay server for registration confirmation and authentication purpose.
- `/api/method/frappe.push_notification.subscribe?fcm_token=<fcm_token_retrieved_from_js_client>`: This API provide support to register end-user device token / FCM token to notification relay server.
For example - This endpoint can be called from web app, when the end-user subscribe for push notification
- `/api/method/frappe.push_notification.unsubscribe?fcm_token=<fcm_token_retrieved_from_js_client>`: This API provide support to de-register end-user device token / FCM token to notification relay server.
For example - This endpoint can be called from web app, when the end-user logout from the application.
`no-docs` (temp)
I’'m pretty sure that some new about this would be coming