Sha256: ae05ae046c175e787697d7c4804972c3399ea346c099390a4fd917f53fb55e77

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 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: false // Automatically dismiss the notification after ~20 seconds in Chrome Deskop 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: true
        });
    };
}

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-onesignal-1.1.1 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-1.1.0 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-1.0.1 vendor/assets/javascripts/devise-onesignal.js.erb
devise-onesignal-1.0.0 vendor/assets/javascripts/devise-onesignal.js.erb