diff --git a/README.md b/README.md index a7b99309..cdefdf40 100644 --- a/README.md +++ b/README.md @@ -240,8 +240,9 @@ modules: [ // Options oneSignal: { - appId: 'YOUR_APP_ID', - // ...your other init settings (see references below) + init: { + appId: 'YOUR_APP_ID', + } } ``` diff --git a/packages/onesignal/index.js b/packages/onesignal/index.js index db5408f4..1d26ce4c 100755 --- a/packages/onesignal/index.js +++ b/packages/onesignal/index.js @@ -41,18 +41,17 @@ function addOneSignal (moduleOptions) { // Merge options const defaults = { - // Special options OneSignalSDK: undefined, cdn: false, GcmSenderId: '482941778795', importScripts: [ '/sw.js' ], - // SDK init options - // https://documentation.onesignal.com/docs/web-push-sdk#section--init- - allowLocalhostAsSecureOrigin: true, - welcomeNotification: { - disable: true + init: { + allowLocalhostAsSecureOrigin: true, + welcomeNotification: { + disable: true + } } } @@ -117,20 +116,12 @@ function addOneSignal (moduleOptions) { makeSW('OneSignalSDKWorker.js', [].concat(options.importScripts || []).concat(options.OneSignalSDK)) makeSW('OneSignalSDKUpdaterWorker.js', [options.OneSignalSDK]) - // Add OneSignal init plugin - const onsOpts = Object.assign({}, options) - delete onsOpts.OneSignalSDK - delete onsOpts.cdn - delete onsOpts.GcmSenderId - delete onsOpts.importScripts - + // Add OneSignal plugin this.addPlugin({ src: path.resolve(__dirname, 'templates/plugin.js'), ssr: false, fileName: 'onesignal.js', - options: { - onsOpts - } + options }) } diff --git a/packages/onesignal/templates/plugin.js b/packages/onesignal/templates/plugin.js index 71119059..ab7c9044 100755 --- a/packages/onesignal/templates/plugin.js +++ b/packages/onesignal/templates/plugin.js @@ -1,6 +1,6 @@ window.$OneSignal = window.OneSignal = window.OneSignal || []; -OneSignal.push(['init', <%= JSON.stringify(options.onsOpts, null, 2) %>]); +OneSignal.push(['init', <%= JSON.stringify(options.init, null, 2) %>]); export default function (ctx, inject) { inject('OneSignal', OneSignal) diff --git a/test/fixture/nuxt.config.js b/test/fixture/nuxt.config.js index f2240e12..e1267b10 100644 --- a/test/fixture/nuxt.config.js +++ b/test/fixture/nuxt.config.js @@ -33,6 +33,8 @@ module.exports = { ] }, oneSignal: { - appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f' + init: { + appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f' + } } }