var OneSignal = OneSignal || []; OneSignal.push(["init", { welcomeNotification: { disable: true }, appId: "6eee0595-7d9f-4bd4-9cc8-5163c69775e7", autoRegister: false, subdomainName: 'gigazine', safari_web_id: "web.onesignal.auto.5f176c09-6482-49c9-87ea-0c57aa3981a0", notifyButton: { enable: false }, slidedown: { enabled: false, autoPrompt: false }, promptOptions: { actionMessage: '通知設定', exampleNotificationTitleDesktop: 'sample:GIGAZINE', exampleNotificationMessageDesktop: 'sample:今日のヘッドライン', exampleNotificationTitleMobile: ' sample:GIGAZINE', exampleNotificationMessageMobile: 'sample:今日のヘッドライン', exampleNotificationCaption: '(通知設定はいつでも停止できます)', acceptButtonText: '通知を許可する', cancelButtonText: '通知は行わない', showCredit : false, slidedown: { prompts: [ { type: "push", autoPrompt: false, text: { actionMessage: "通知設定", acceptButton: "通知を許可する", cancelButton: "通知は行わない" }, delay: { pageViews: 100, timeDelay: 300 } } ] } } }]); OneSignal.push(["isPushNotificationsEnabled", function(enabled) { if (enabled){ $("#push_on").show(); } else{ $("#push_off").show(); } }]); $('header').on('click','#push_off',function(event){ $("#push_off").hide(); $("#push_on").show(); OneSignal.push(["registerForPushNotifications"]); var ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf('safari') != -1) { OneSignal.push(["setSubscription", true]); } event.preventDefault(); }); $('header').on('click','#push_on',function(event){ $("#push_on").hide(); $("#push_off").show(); OneSignal.push(["setSubscription", false]); event.preventDefault(); });