A repository with a sample TWA application.
This code is published and available here.
The PWA application receives a token from query params (if it is not there, then it offers to enter), and on an event it sends a request to create a notification, adding the token to the request body.
You can learn more from this article.