Skip to content

Commit cd4ddb4

Browse files
author
Rodrigo Gomez Palacio
authored
Merge pull request #56 from OneSignal/update-readme
Update README to include Service Worker config info
2 parents 18e7825 + f28a075 commit cd4ddb4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,27 @@ OneSignal.init({ appId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }).then(() => {
7171
})
7272
```
7373

74-
### Options
74+
### Init Options
7575
You can pass other [options](https://documentation.onesignal.com/docs/web-push-sdk#init) to the `init` function. Use these options to configure personalized prompt options, auto-resubscribe, and more.
7676

77+
**Service Worker Params**
78+
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).
79+
80+
In this distribution, you can specify the parameters via the following:
81+
82+
| Field | Details |
83+
|----------------------------|------------------------------------------------------------------------------------------------------------------------|
84+
| `serviceWorkerParam` | Use to specify the scope, or the path the service worker has control of. Example: `{ scope: "/js/push/onesignal/" }` |
85+
| `serviceWorkerPath` | The path to the service worker file. |
86+
87+
### Service Worker File
88+
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)).
89+
90+
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).
91+
92+
**Tip:**
93+
Visit `https://yoursite.com/OneSignalSDKWorker.js` in the address bar to make sure the files are being served successfully.
94+
7795
---
7896
## OneSignal API
7997
### Typescript

0 commit comments

Comments
 (0)