how to test Onesignal push notifications on localhost?

Viewed 17682

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 ?

6 Answers

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

For anyone else struggling with this, the answer is to add 'http://localhost' but when the configurator comes back with a message similar to 'localhost is already taken. Please enter a different name.' jut scroll down and type in a different subdomain. It's not very intuitive but that worked for me.

In order to test onesignal push notifications over localhost, you should enable https://localhost on your test environment. The following great post help me to setup it on macos, but I think you could implement it in other operative systems:

https://medium.com/@jonsamp/how-to-set-up-https-on-localhost-for-macos-b597bcf935ee

When you are able to start your web server at https://localhost:8080 , you should configure on OneSignal App the following:

Site Url :  https://localhost:8080
Check "My site not fully HTTPS"
CHOOSE A LABEL :  your-test-env.OS.TC

By completing the setup suggested by Onesignal documentation, you will be able to test push notifications on your test environment.

Related