Works with OneSignal to allow site visitors to choose specific categories of notifications to get when they sign up for push notifications by adding data tags on signup.
Please note, this is still an early pre-release of this plugin, and it is still being tested. Features may change and break (or not work to begin with!) or it could conflict with your site in unexpected ways. Not intended for installation on production sites!
The easiest way to install is to download the latest release.
Push Notification User Tags extends the OneSignal plugin to add an interface for site visitors to choose their notification categories and an admin interface to choose which categories should receive push notifications for any given post publish/update.
This plugin adds a new settings page under the OneSignal plugin.
This section includes settings for letting users select notification categories to subscribe to.
Here's where you define the categories users can subscribe to.
For each category you can set:
- Key - The actual tag value that will be sent to OneSignal (you can see this under "tags" in the OneSignal dashboard). Changing a category's key will effectively create a new category and you will no longer be able to push to the old key from the post editing screen
- Label - This is only used within WordPress to identify the category for site visitors and administrators. It is not sent to OneSignal. You can change the label at any time without affecting subscriptions/pushes to the underlying key.
- Visible in popup - Whether or not to show this category in the popup that's triggered by clicking on the bell notification icon (see below)
- Checked by default in popup - Whether or not this category is pre-selected in the bell popup for users who haven't selected any categories yet.
Settings for the popup window that appears when the bell icon is clicked.
There are two sections:
- For users who are not subscribed is shown to users who are not currently subscribed to notifications (including users who have de-selected all notification categories)
- For users who are currently subscribed is shown to users who have given permission for notifications and are signed up for at least one notification category
Each section has a rich text area (to edit the content that goes before the category checkboxes) and a field to edit the text for the submit button.
This setting enables a floating notification bell. It is similar to the feature in the OneSignal WordPress plugin, but launches a popup to allow users to select categories before triggering the native browser notification permission prompt.
This bell icon is only available when the OneSignal bell is turned off. If the OneSignal bell is on, it will replace this feature.
This plugin includes a "Push notification signups" block to create a signup form showing available notification categories.
- The two sections at the top are block areas which are shown to users who are not currently subscribed to any notifications and those who are, respectively. These sections can hold any blocks (click the plus button to add blocks to them.)
- In the list of categories, turning off the eye icon will hide that category in this signup block (but not elsewhere), and checking the checkbox will pre-select it for visitors who do not already have their own notification category preferences set up.
- Select the list of categories for more options in the right-hand block settings, including how many columns to use for display and how to handle new categories that are added with the admin settings page after this block is edited.
- Select the signup button for all the settings normally available for buttons (please note that links will have no effect since this button just submits the categories above).
- The "subscribed user button text" field will replace the text shown on the button for users who are currently subscribed.
In addition to the push controls meta box added by the OneSignal WordPress plugin, this plugin adds a list of categories.
These checkboxes are only enabled when the OneSignal "Send notification on post publish/update" is selected. The post will be pushed to all users who have signed up for any of the categories selected when the post is published/updated.
npm install
npm run build