Skip to content

Commit 182427d

Browse files
author
pooya parsa
committed
chore: initial commit
0 parents  commit 182427d

24 files changed

+11790
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_size = 2
6+
indent_style = space
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
.nuxt
4+
coverage
5+
templates/*
6+
example/static

.eslintrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
parser: 'babel-eslint',
5+
sourceType: 'module'
6+
},
7+
extends: [
8+
'@nuxtjs'
9+
]
10+
}

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
ci:
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
node: [10, 12]
19+
20+
steps:
21+
- uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node }}
24+
25+
- name: checkout
26+
uses: actions/checkout@master
27+
28+
- name: cache node_modules
29+
uses: actions/cache@v1
30+
with:
31+
path: node_modules
32+
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
33+
34+
- name: Install dependencies
35+
if: steps.cache.outputs.cache-hit != 'true'
36+
run: yarn
37+
38+
- name: Lint
39+
run: yarn lint
40+
41+
- name: Test
42+
run: yarn test
43+
44+
- name: Coverage
45+
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
*.iml
3+
.idea
4+
*.log*
5+
.nuxt
6+
.vscode
7+
.DS_Store
8+
coverage

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) pooya parsa <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# OneSignal Module
2+
3+
[![npm version][npm-version-src]][npm-version-href]
4+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
5+
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
6+
[![Codecov][codecov-src]][codecov-href]
7+
[![License][license-src]][license-href]
8+
9+
OneSignal is a Free, high volume and reliable push notification service for websites and mobile applications. Setting and using this module is a little tricky as OneSignal requires to register its own Service worker.
10+
11+
## Setup
12+
13+
1. Follow steps to insall [pwa module](https://pwa.nuxtjs.org)
14+
15+
2. Add `@nuxtjs/onesignal` dependency to your project
16+
17+
```bash
18+
yarn add @nuxtjs/onesignal # or npm install @nuxtjs/onesignal
19+
```
20+
21+
2. Add `@nuxtjs/onesignal` **BEFORE** `@nuxtjs/pwa` to the `modules` section of `nuxt.config`:
22+
23+
```js
24+
modules: [
25+
'@nuxtjs/onesignal',
26+
'@nuxtjs/pwa'
27+
]
28+
```
29+
30+
3. Add `oneSignal` options to `nuxt.config`:
31+
32+
```js
33+
// Options
34+
oneSignal: {
35+
init: {
36+
appId: 'YOUR_APP_ID',
37+
allowLocalhostAsSecureOrigin: true,
38+
welcomeNotification: {
39+
disable: true
40+
}
41+
}
42+
}
43+
```
44+
45+
See references below for all `init` options.
46+
47+
4. Add `OneSignalSDK*` to `.gitignore`
48+
49+
## Async Functions
50+
This module exposes oneSignal as `$OneSignal` everywhere. So you can call it.
51+
Please note that because of async loading of OneSignal SDK script, every action should be pushed into `$OneSignal` stack.
52+
53+
```js
54+
// Inside page components
55+
this.$OneSignal.push(() => {
56+
this.$OneSignal.isPushNotificationsEnabled((isEnabled) => {
57+
if (isEnabled) {
58+
console.log('Push notifications are enabled!')
59+
} else {
60+
console.log('Push notifications are not enabled yet.')
61+
}
62+
})
63+
})
64+
65+
// Using window and array form
66+
window.$OneSignal.push(['addListenerForNotificationOpened', (data) => {
67+
console.log('Received NotificationOpened:', data )}
68+
]);
69+
```
70+
71+
## Change OneSignal SDK Script URL
72+
73+
By default this modules ships with latest SDK dist.
74+
75+
You can use recommended CDN by using `cdn: true` or changing it to a custom value using `OneSignalSDK`.
76+
77+
```js
78+
oneSignal: {
79+
// Use CDN
80+
cdn: true,
81+
82+
// Use any custom URL
83+
OneSignalSDK: 'https://cdn.onesignal.com/sdks/OneSignalSDK.js'
84+
}
85+
```
86+
87+
## References
88+
89+
- [Web Push SDK Reference](https://documentation.onesignal.com/docs/web-push-sdk) - Available options and API calls
90+
- [Customize Permission Messages](https://documentation.onesignal.com/docs/customize-permission-messages)
91+
- [Thanks for Subscribing Notifications](https://documentation.onesignal.com/docs/welcome-notifications)
92+
- [Product overview](https://documentation.onesignal.com/docs/product-overview) - More info about OneSignal
93+
- [Web Push SDK Setup](https://documentation.onesignal.com/docs/web-push-sdk-setup-https) - Setup guides for in-depth reading what this modules does.
94+
95+
## License
96+
97+
[MIT License](./LICENSE)
98+
99+
<!-- Badges -->
100+
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/onesignal/latest.svg
101+
[npm-version-href]: https://npmjs.com/package/@nuxtjs/onesignal
102+
103+
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/onesignal.svg
104+
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/onesignal
105+
106+
[github-actions-ci-src]: https://github.com/nuxt-community/onesignal-module/workflows/ci/badge.svg
107+
[github-actions-ci-href]: https://github.com/nuxt-community/onesignal-module/actions?query=workflow%3Aci
108+
109+
[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/onesignal-module.svg
110+
[codecov-href]: https://codecov.io/gh/nuxt-community/onesignal-module
111+
112+
[license-src]: https://img.shields.io/npm/l/@nuxtjs/onesignal.svg
113+
[license-href]: https://npmjs.com/package/@nuxtjs/onesignal

babel.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env', {
5+
targets: {
6+
esmodules: true
7+
}
8+
}
9+
]
10+
]
11+
}

commitlint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
extends: [
3+
'@commitlint/config-conventional'
4+
]
5+
}

dist/OneSignalSDK.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)