how to test Onesignal push notifications on localhost?

15,968

Solution 1

It should be https://localhost not http://localhost. OneSignal treats localhost as secure connections.

Solution 2

Besides configuring OneSignal via dashboard, your OneSignal.init in your browser call must have the allowLocalhostAsSecureOrigin option:

OneSignal.init({
  allowLocalhostAsSecureOrigin: true,
  ...
})

More at https://documentation.onesignal.com/docs/web-push-setup-faq#section-how-do-i-test-my-site-on-a-local-environment

Solution 3

read in this doc https://documentation.onesignal.com/docs/web-push-setup-faq#section-how-do-i-test-my-site-on-a-local-environment- and localhost must run in port 8000

Solution 4

You may use Postman. Just follow this steps, found at: One Signal documentation

Surprisingly, simple. Enjoy.

Share:
15,968
Abdelaziz Mokhnache
Author by

Abdelaziz Mokhnache

Updated on June 14, 2022

Comments

  • Abdelaziz Mokhnache
    Abdelaziz Mokhnache about 2 years

    I want to test OneSignal push notifications on localhost before I deploy my app to a remote server.

    I followed the instructions provided by the documentation. When I enter http://localhost as the site url I get an error message that says:

    localhost is already taken. Please enter a different name.

    Is there a way to use OneSignal on localhost ?

  • natterstefan
    natterstefan over 6 years
    This may not be related, but I assume you got localhost working. Did you get the same issue like I get here: github.com/OneSignal/OneSignal-Website-SDK/issues/281. If yes, how do you solved it?
  • Abdelaziz Mokhnache
    Abdelaziz Mokhnache over 6 years
    sorry @StefanN. I got localhost working but I didn't get your an issue similar to your one .. I followed the official docs and it was fine