Sending Push Notification with Pushwoosh
What You'll Need
Backbench account - Sign Up, the personal account will always remain free to use.
Pushwoosh account - It helps you address your audience with highly customizable push notifications. Speak to the users on their own language, deliver your values and push the world.
Google account - _Firebase _is Google's mobile platform that helps you quickly develop high-quality apps and grow your business.
Prerequisites for the app
Open the FireBase Console. And create a new project. Click on ‘+Add project’ to create a new project.
Go to your Project Settings
Make a note of the server key and sender id. Never share your secret keys.
Go to the link “https://www.pushwoosh.com/docs/web-push-sdk-30”. Now Download Pushwoosh Web Push SDK.
Extract the file. You will have two files “manifest.json” and “pushwoosh-service-worker.js”.
Now open Backbench.
Go to your bench. And open the File Manager.
Here click on the + button in the corner.
From the dropdown click ‘Upload’
Drag the “manifest.json” to the dialogue box.
Make sure that the Folder path is set to root that is “/”.
Click on Upload.
Do the same with “pushwoosh-service-worker.js”.
Now open the “manifest.json”, by clicking in the three dots and then clicking Edit from the dropdown.
Change name and short\_name to the name of your website. This is the URL that you can find by going to the Endpoint section in Backbench.
Change gcm\_sender\_id to your Sender ID. Please keep in mind that Sender ID is usually a 12-digit number, and it can't contain any letters.
Now go to the + sign. Create a file called new.html.
Put the below code in the file.
Frontend
Copy and paste the code module from below.
Select save.
Backend
Now go and create an account at pushwoosh.com.
You will be taken to the Pushwoosh Control Panel. Here click on +AddNew to add a new application.
After you have created your application, you can find the Application code in the control panel of your app.
Substitute this application code in the code at step 18 in place of XXXX-XXXX applicationCode: 'XXXX-XXXX'
In the pushwoosh control panel go to Configure. Go to Chrome and click on configure.
Put the Server key and Sender ID from Step 3 in place of API key and GCM Sender ID respectively.
Now go to Backbench. Navigate to your bench and then go to modules. Create a “package.json” file, by clicking the + button.
In package.json write the following code.
Then go back and create a js file called pushwoosh.js. Write the following code.
After this go to the pushwoosh control panel.
Send a push by creating the push message and then send.
You will get a notification from the endpoint and you will also get the required message.
Last updated