Sha256: bf5b3dbd6f249892d24e77b09e4c17e3b59d73bfde49aa5e4a1f834505b6660a

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

var OneSignalPlayerId = null;
var OneSignal = window.OneSignal || [];



function OneSignalInit() {

    OneSignal.push([ 'init', {
        appId: '<%= DeviseOnesignal.configuration.app_id %>',
        autoRegister: <%= DeviseOnesignal.configuration.auto_register ? 'true' : 'false' %>,
        welcomeNotification: {
            disable: true,
            title: '',
            message: ''
        },
        notifyButton: {
            enable: false
        },
        persistNotification: <%= DeviseOnesignal.configuration.persist_notification ? 'true' : 'false' %> // Automatically dismiss the notification after ~20 seconds in Chrome Desktop v47+
    }]);

    OneSignal.push(function() {
        OneSignal.getUserId().then(function(playerId) {
            if ( playerId != null ) {
                OneSignalPlayerId = playerId;
                document.cookie = 'oneSignalPlayerId=' + playerId;
            };
            OneSignal.push([ 'getNotificationPermission', function(permission) {
                document.cookie = 'oneSignalPlayerPermission=' + permission;
            }]);
        });
    });

};



function OneSignalSubscribe() {
    if ( OneSignalPlayerId != null ) {
        OneSignal.setSubscription(true);
    } else {
        OneSignal.registerForPushNotifications({
            modalPrompt: <%= DeviseOnesignal.configuration.subscribe_with_modal ? 'true' : 'false' %>
        });
    };
}

function OneSignalUnsubscribe() {
    OneSignal.setSubscription(false);
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
devise-onesignal-3.1.5 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.1.4 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.1.3 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.1.2 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.1.1 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.1.0 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.0.2 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.0.1 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-3.0.0 vendor/assets/javascripts/devise-onesignal.js.erb