Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Extend WebPushMessage with the custom settings #20304

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mshabarov
Copy link
Contributor

@mshabarov mshabarov commented Oct 22, 2024

Description

Adds an API to set custom options as described in https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification#parameters

Fixes #20285

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

Copy link

github-actions bot commented Oct 22, 2024

Test Results

1 142 files  ± 0  1 142 suites  ±0   1h 26m 27s ⏱️ + 1m 48s
7 477 tests ± 0  7 427 ✅ ± 0  50 💤 ±0  0 ❌ ±0 
7 766 runs   - 47  7 708 ✅  - 47  58 💤 ±0  0 ❌ ±0 

Results for commit b62e1c8. ± Comparison against base commit bae8c0e.

♻️ This comment has been updated with latest results.

@mshabarov
Copy link
Contributor Author

To note: I'm working on figuring out how can we provide an API for adding action listener, else than asking to extend the service worker (sw.js).

Also this needs some testing on mobile.

* @param options any Serializable Java Object representing custom settings that you want to apply to the notification
* @see <a href=https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification#parameters</a>
*/
public WebPushMessage(String title, Serializable options) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider providing a proper java class / record for the options instead of just Serializable?

Copy link
Contributor Author

@mshabarov mshabarov Nov 1, 2024

Choose a reason for hiding this comment

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

The reason why I didn't add a class for options if because otherwise we should extend or modify it each time when the browser API changed. IMO it's better to decouple the Java API from the browser API that way.

@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Nov 1, 2024
@mshabarov mshabarov marked this pull request as ready for review November 1, 2024 14:20
@mshabarov mshabarov marked this pull request as draft November 1, 2024 14:22
Copy link

sonarcloud bot commented Nov 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make WebPushMessage output customisable
3 participants