how to test Onesignal push notifications on localhost?
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,
...
})
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
- Select POST and use url https://onesignal.com/api/v1/notifications
- Set headers, like this:
- And, finally, add the push body
Surprisingly, simple. Enjoy.
Abdelaziz Mokhnache
Updated on June 14, 2022Comments
-
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 over 6 yearsThis 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 over 6 yearssorry @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