Push Notification Sender

This val can be used in other vals to send notifications to a segment using OneSignal's REST API

This is really handy if you want to send push notifications to your phone without building a native app! I built a barebones React PWA that asks for a password then loads the OneSignal Web SDK that I deployed to Netlify for free. OneSignal has easy to follow docs so you can build this functionality into a React, Angular, Vue app or even Wordpress! Then install the PWA on your platform of choice and you're off to the races!

Setup

  1. Save your ONESIGNAL_TOKEN and SEGMENT_APPID from OneSignal to your Val Town environment variables

  2. Import into another val!

import sendNotification from "https://esm.town/v/gwoods22/sendNotification";