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

PWA Push notification #4995

Closed
aminsource opened this issue Sep 10, 2018 · 5 comments
Closed

PWA Push notification #4995

aminsource opened this issue Sep 10, 2018 · 5 comments
Labels

Comments

@aminsource
Copy link

Expected Behavior

Is anyway for implementation push notification in create-react-app without ejecting?
and is any plan to implementation natively?

@nikitowsky
Copy link

Why do you need ejecting? It's all about service workers and Push API/Notification API, isn't it?

@aminsource
Copy link
Author

aminsource commented Sep 11, 2018

yes but I need to customize of service worker for it

I find some answer here #2253 👍

@peterbe
Copy link

peterbe commented Oct 25, 2018

Somewhere in your app...

function requestNotificationPermission() {
  // Some browsers don't support Notification yet. I'm looking at you iOS Safari
  if ("Notification" in window) {
    if (
      Notification.permission !== "denied" &&
      Notification.permission !== "granted"
    ) {
      Notification.requestPermission();
    }
  }
}

and somewhere else in your app...

if ("Notification" in window && Notification.permission === "granted") {
  new Notification("You just got poked!");
}

No need to eject. For sure. If you want to integrate it into your service worker, use the src/serviceWorker.js and make modifications to it as needed.

@stale
Copy link

stale bot commented Nov 24, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Nov 24, 2018
@stale
Copy link

stale bot commented Nov 29, 2018

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Nov 29, 2018
@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants