You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This is a JavaScript module that can be used to easily include [OneSignal](https://onesignal.com/) code in a website or app that uses Vue for its front-end codebase.
OneSignal is the world's leader for Mobile Push Notifications, Web Push, and In-App Messaging. It is trusted by 2 million+ businesses to send 9 billion Push Notifications per day.
23
23
24
24
You can find more information on OneSignal [here](https://onesignal.com/).
25
25
26
26
> Upgrading from Version 1?
27
-
See our [migration guide](./MigrationGuide.md) to get started with v2.
27
+
> See our [migration guide](./MigrationGuide.md) to get started with v2.
28
28
29
29
## Contents
30
+
30
31
-[Install](#install)
31
32
-[Usage](#usage)
32
33
-[API](#onesignal-api)
33
34
-[Advanced Usage](#advanced-usage)
34
35
35
36
---
37
+
36
38
## Vue Compatibility
39
+
37
40
Make sure you install a plugin version compatible with your Vue environment.
The OneSignal plugin automatically exposes a `$OneSignal` global property accessible inside the application.
@@ -98,123 +108,140 @@ The OneSignal plugin automatically exposes a `$OneSignal` global property access
98
108
You can also leverage Vue's [Composition API](https://vuejs.org/guide/extras/composition-api-faq.html) via the `useOneSignal` function that can be called from within [`setup`](https://vuejs.org/api/composition-api-setup.html#basic-usage).
99
109
100
110
## Reference
111
+
101
112
### Initialization
113
+
102
114
The `init` function returns a promise that resolves when OneSignal is loaded.
You can pass other [options](https://documentation.onesignal.com/v11.0/docs/web-sdk#initializing-the-sdk) to the `init` function. Use these options to configure personalized prompt options, auto-resubscribe, and more.
|`autoRegister`|`boolean` (optional) | Whether or not to automatically register the user.|
142
+
|`autoResubscribe`|`boolean` (optional) | Whether or not to automatically resubscribe the user.|
143
+
|`path`|`string` (optional) | The path to the OneSignal service worker file.|
144
+
|`serviceWorkerPath`|`string` (optional) | The path to the OneSignal service worker script.|
145
+
|`serviceWorkerUpdaterPath`|`string` (optional) | The path to the OneSignal service worker updater script. |
146
+
|`subdomainName`|`string` (optional) | The subdomain of your OneSignal app.|
147
+
|`allowLocalhostAsSecureOrigin`|`boolean` (optional) | Whether or not to allow localhost as a secure origin.|
148
+
|`requiresUserPrivacyConsent`|`boolean` (optional) | Whether or not the user's consent is required.|
149
+
|`persistNotification`|`boolean` (optional) | Whether or not notifications should persist.|
150
+
|`notificationClickHandlerMatch`|`string` (optional) | The URL match pattern for notification clicks.|
151
+
|`notificationClickHandlerAction`|`string` (optional)| The action to perform when a notification is clicked.|
152
+
|`welcomeNotification`|`object` (optional) | The welcome notification configuration.|
153
+
|`notifyButton`|`object` (optional) | The notify button configuration.|
154
+
|`promptOptions`|`object` (optional) | Additional options for the subscription prompt.|
155
+
|`webhooks`|`object` (optional) | The webhook configuration.|
156
+
|`[key: string]`|`any`| Additional properties can be added as needed.|
141
157
142
158
**Service Worker Params**
143
159
You can customize the location and filenames of service worker assets. You are also able to specify the specific scope that your service worker should control. You can read more [here](https://documentation.onesignal.com/docs/onesignal-service-worker-faq#sdk-parameter-reference-for-service-workers).
144
160
145
161
In this distribution, you can specify the parameters via the following:
|`serviceWorkerParam`| Use to specify the scope, or the path the service worker has control of. Example: `{ scope: "/js/push/onesignal/" }`|
166
+
|`serviceWorkerPath`| The path to the service worker file. |
151
167
152
168
</details>
153
169
154
170
---
155
171
156
172
### Service Worker File
157
-
If you haven't done so already, you will need to add the [OneSignal Service Worker file](https://github.com/OneSignal/OneSignal-Website-SDK/files/7585231/OneSignal-Web-SDK-HTTPS-Integration-Files.zip) to your site ([learn more](https://documentation.onesignal.com/docs/web-push-quickstart#step-6-upload-files)).
173
+
174
+
If you haven't done so already, you will need to add the [OneSignal Service Worker file](https://github.com/OneSignal/OneSignal-Website-SDK/files/11480764/OneSignalSDK-v16-ServiceWorker.zip) to your site ([learn more](https://documentation.onesignal.com/docs/web-push-quickstart#step-6-upload-files)).
158
175
159
176
The OneSignal SDK file must be publicly accessible. You can put them in your top-level root or a subdirectory. However, if you are placing the file not on top-level root make sure to specify the path via the service worker params in the init options (see section above).
160
177
161
178
**Tip:**
162
179
Visit `https://yoursite.com/OneSignalSDKWorker.js` in the address bar to make sure the files are being served successfully.
163
180
164
181
### Code completion
182
+
165
183
If IntelliSense is not working as expected in your `.vue` file, try adding an import from the OneSignal plugin.
0 commit comments