Skip to content

Commit dd61c18

Browse files
author
Pooya Parsa
committedNov 17, 2017
feat(onesignal): move init options under init
1 parent f3b5b3e commit dd61c18

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed
 

Diff for: ‎README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ modules: [
240240

241241
// Options
242242
oneSignal: {
243-
appId: 'YOUR_APP_ID',
244-
// ...your other init settings (see references below)
243+
init: {
244+
appId: 'YOUR_APP_ID',
245+
}
245246
}
246247
```
247248

Diff for: ‎packages/onesignal/index.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,17 @@ function addOneSignal (moduleOptions) {
4141

4242
// Merge options
4343
const defaults = {
44-
// Special options
4544
OneSignalSDK: undefined,
4645
cdn: false,
4746
GcmSenderId: '482941778795',
4847
importScripts: [
4948
'/sw.js'
5049
],
51-
// SDK init options
52-
// https://documentation.onesignal.com/docs/web-push-sdk#section--init-
53-
allowLocalhostAsSecureOrigin: true,
54-
welcomeNotification: {
55-
disable: true
50+
init: {
51+
allowLocalhostAsSecureOrigin: true,
52+
welcomeNotification: {
53+
disable: true
54+
}
5655
}
5756
}
5857

@@ -117,20 +116,12 @@ function addOneSignal (moduleOptions) {
117116
makeSW('OneSignalSDKWorker.js', [].concat(options.importScripts || []).concat(options.OneSignalSDK))
118117
makeSW('OneSignalSDKUpdaterWorker.js', [options.OneSignalSDK])
119118

120-
// Add OneSignal init plugin
121-
const onsOpts = Object.assign({}, options)
122-
delete onsOpts.OneSignalSDK
123-
delete onsOpts.cdn
124-
delete onsOpts.GcmSenderId
125-
delete onsOpts.importScripts
126-
119+
// Add OneSignal plugin
127120
this.addPlugin({
128121
src: path.resolve(__dirname, 'templates/plugin.js'),
129122
ssr: false,
130123
fileName: 'onesignal.js',
131-
options: {
132-
onsOpts
133-
}
124+
options
134125
})
135126
}
136127

Diff for: ‎packages/onesignal/templates/plugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
window.$OneSignal = window.OneSignal = window.OneSignal || [];
22

3-
OneSignal.push(['init', <%= JSON.stringify(options.onsOpts, null, 2) %>]);
3+
OneSignal.push(['init', <%= JSON.stringify(options.init, null, 2) %>]);
44

55
export default function (ctx, inject) {
66
inject('OneSignal', OneSignal)

Diff for: ‎test/fixture/nuxt.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ module.exports = {
3333
]
3434
},
3535
oneSignal: {
36-
appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f'
36+
init: {
37+
appId: 'd867ac26-f7be-4c62-9fdd-b756a33c4a8f'
38+
}
3739
}
3840
}

0 commit comments

Comments
 (0)
Please sign in to comment.