Support » Plugin: OneSignal - Web Push Notifications » Custom function for notification checkbox toggle

  • Resolved Adriano Monecchi


    The following code shows how to Trigger Custom Link Permission Message.

    I’d like to allow the user to subscribe/unsubscribe by clicking on a checkbox toggle. Is there a way to make this happen by passing additional parameters to OneSignal while checking for the checkbox toggle value?

        <a href="#" id="subscribe-link" style="display: none;">Subscribe to Notifications</a>
            function subscribe() {
            var OneSignal = OneSignal || [];
            /* This example assumes you've already initialized OneSignal */
            OneSignal.push(function() {
                // If we're on an unsupported browser, do nothing
                if (!OneSignal.isPushNotificationsSupported()) {
                OneSignal.isPushNotificationsEnabled(function(isEnabled) {
                    if (isEnabled) {
                        // The user is subscribed to notifications
                        // Don't show anything
                    } else {
                        document.getElementById("subscribe-link").addEventListener('click', subscribe);
                        document.getElementById("subscribe-link").style.display = '';
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom function for notification checkbox toggle’ is closed to new replies.