Sha256: bcd22899b386be6223c583c7270bbec255824b012d72822e63a273a075396aca

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

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



function OneSignalInit() {

    // Do NOT call init() twice
    OneSignal.push([ 'init', {
        // Your other init options here
        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+
    }]);

    // Firstly this will check user id
    OneSignal.push(function() {
        OneSignal.getUserId().then(function(userId) {
            if ( userId != null ) {
                useragentid = userId;
                document.cookie = 'oneSignalUserId=' + userId;
            };
            OneSignal.push([ 'getNotificationPermission', function(permission) {
                document.cookie = 'oneSignalUserPermission=' + permission;
            }]);
        });
    });

};



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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-onesignal-1.2.1 vendor/assets/javascripts/devise-onesignal.js.erb