
We can also send data to tags that will be used in order to segment users on the OneSignal platform. (This will be shown in the next section.) This is necessary to send the push notification to a specific user. If the user has been subscribed, we’ll receive the OneSignal ID of the user to store in our database. With the subscriptionChange method, we can check if the user was subscribed. In the JavaScript code, we will need only the APP ID. Additionally, create a function that should be called in the load of the page where the OneSignal button will show up. Add the script tag below the head tag of your webpage to import the OneSignal scripts. The subscription of users will require JavaScript code. Now, in the Settings, click on “Keys & IDs” to get the APP ID and the REST API Key. After finishing these steps, just click on “Save” to complete the Web Push integration. You can also configure the welcome message push and the webhook when the user clicks on push notifications.


If the test is with a not fully HTTPS site, set up the HTTP pop-up as well. Next, add and customize the Subscription Bell. For localhost tests, select “My site is not fully HTTPS.” Then, fill in the Site Name, Site URL, and choose a Label. Now, click on “Typical Site” to create the default integration. Next, click on “Settings” to set up Web Push notifications on Chrome. Creating a new appįirst, create an account with OneSignal and then click on “Add a new app.” The same implementation shown here can be used to send Web Push notifications to mobile apps, but that will not be demonstrated here. We will then subscribe a user to receive notifications and send them to both one and all subscribed users. In this article, we will implement a solution to send Web Push notifications with OneSignal in a Ruby on Rails project.
