Permalink
Browse files

feat(onesignal): move init options under init

  • Loading branch information...
pi0 committed Nov 17, 2017
1 parent f3b5b3e commit dd61c18093ada4ed936c08b6a25a96d7f93cdfbb
Showing with 14 additions and 20 deletions.
  1. +3 −2 README.md
  2. +7 −16 packages/onesignal/index.js
  3. +1 −1 packages/onesignal/templates/plugin.js
  4. +3 −1 test/fixture/nuxt.config.js
@@ -240,8 +240,9 @@ modules: [
// Options
oneSignal: {
appId: 'YOUR_APP_ID',
// ...your other init settings (see references below)
init: {
appId: 'YOUR_APP_ID',
}
}
```
@@ -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
})
}
@@ -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)
@@ -33,6 +33,8 @@ module.exports = {
]
},
oneSignal: {
appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f'
init: {
appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f'
}
}
}

0 comments on commit dd61c18

Please sign in to comment.