Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Add support for custom events fired by clicking on notifications. #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/server/api/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {notifyLaravel} from "../utils";
const router = express.Router();

router.post('/', (req, res) => {
const {title, body} = req.body
const {title, body, customEvent: event} = req.body

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const {title, body, customEvent: event} = req.body
const {title, body, event: customEvent} = req.body

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to also submit suggestions for line 8? And I'm not actually sure what the response from the API is for retrieving the event name provided when registering a notification.

const eventName = customEvent ?? '\\Native\\Laravel\\Events\\Notifications\\NotificationClicked';

const notification = new Notification({title, body});

notification.on("click", (event)=>{
notifyLaravel('events', {
event: '\\Native\\Laravel\\Events\\Notifications\\NotificationClicked',
payload: []
event: eventName,
payload: JSON.stringify(event)
})
})

Expand Down