@gapi/onesignal-notifications 1.8.151 → 1.8.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +59 -59
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -2,10 +2,12 @@
2
2
 
3
3
  #### @Gapi OneSignal Notifications module @StrongTyped forked and re-written with typescript from [onesignal-node](https://github.com/KolektifLabs/onesignal-node)
4
4
 
5
- ##### For questions/issues you can write ticket [here](http://gitlab.youvolio.com/gapi/onesignal-notifications/issues)
5
+ ##### For questions/issues you can write ticket [here](https://github.com/Stradivario/gapi/issues)
6
+
6
7
  ##### This module is intended to be used with [GAPI](https://github.com/Stradivario/gapi)
7
8
 
8
9
  ## Installation and basic examples:
10
+
9
11
  ##### To install this Gapi module, run:
10
12
 
11
13
  ```bash
@@ -15,76 +17,77 @@ $ npm install @gapi/onesignal-notifications
15
17
  ## Consuming @gapi/onesignal-notifications
16
18
 
17
19
  ##### Import inside AppModule or CoreModule
18
- ```typescript
19
20
 
21
+ ```typescript
20
22
  import { Module } from '@rxdi/core';
21
23
  import { OneSignalModule } from '@gapi/onesignal-notifications';
22
24
 
23
25
  @Module({
24
- imports: [
25
- OneSignalModule.forRoot({
26
- userAuthKey: 'ZmY2YjVkMjMtMjY0OC00Y2E2LTkxBTQtYTVmOWY1MmJhZDg1',
27
- app: {
28
- appAuthKey: 'MTa4NGIzNjQtNGFkMy00MzY4AWJjZTctNzNjYzYyODgzZDhh',
29
- appId: 'd856cd4h-f834-42cb-b541-22ee20bcf499'
30
- }
31
- })
32
- ],
33
- services: [NotificationService],
34
- effects: [YourCustomEffects]
26
+ imports: [
27
+ OneSignalModule.forRoot({
28
+ userAuthKey: 'ZmY2YjVkMjMtMjY0OC00Y2E2LTkxBTQtYTVmOWY1MmJhZDg1',
29
+ app: {
30
+ appAuthKey: 'MTa4NGIzNjQtNGFkMy00MzY4AWJjZTctNzNjYzYyODgzZDhh',
31
+ appId: 'd856cd4h-f834-42cb-b541-22ee20bcf499',
32
+ },
33
+ }),
34
+ ],
35
+ services: [NotificationService],
36
+ effects: [YourCustomEffects],
35
37
  })
36
- export class CoreModule { }
38
+ export class CoreModule {}
37
39
  ```
38
40
 
39
41
  ##### Create NotificationService
40
42
 
41
43
  ```typescript
42
-
43
44
  import { Service } from '@rxdi/core';
44
45
  import { PurchasesType } from '../../../purchases/types/purchases.type';
45
- import { OneSignalClientService, Notification } from '@gapi/onesignal-notifications';
46
+ import {
47
+ OneSignalClientService,
48
+ Notification,
49
+ } from '@gapi/onesignal-notifications';
46
50
 
47
51
  @Service()
48
52
  export class NotificationService {
49
-
50
- constructor(
51
- private client: OneSignalClientService
52
- ) { }
53
-
54
- async createNotification(purchaseData: PurchasesType) {
55
- const notification: Notification = new Notification({
56
- contents: {
57
- en: 'Test notification',
58
- tr: 'Test mesajı',
59
- bg: 'Съобщение за проба'
60
- }
61
- });
62
- notification.setTargetDevices(['b188dd55-7c70-4072-b696-8b66a56f9c4c']);
63
- notification.setParameter('data', { type: 'notification-created', data: {} });
64
- return await this.client.sendNotification(notification);
65
- }
66
-
67
- async sendNotification() {
68
- const firstNotification = new Notification({
69
- contents: {
70
- en: 'Test notification',
71
- tr: 'Test mesajı',
72
- bg: 'Съобщение за проба'
73
- }
74
- });
75
- firstNotification.setTargetDevices(['b188dd55-7c70-4072-b696-8b66a56f9c4c']);
76
- firstNotification.setParameter('data', { 'abc': '123', 'foo': 'bar' });
77
- return await this.client.sendNotification(firstNotification);
78
- }
79
-
53
+ constructor(private client: OneSignalClientService) {}
54
+
55
+ async createNotification(purchaseData: PurchasesType) {
56
+ const notification: Notification = new Notification({
57
+ contents: {
58
+ en: 'Test notification',
59
+ tr: 'Test mesajı',
60
+ bg: 'Съобщение за проба',
61
+ },
62
+ });
63
+ notification.setTargetDevices(['b188dd55-7c70-4072-b696-8b66a56f9c4c']);
64
+ notification.setParameter('data', {
65
+ type: 'notification-created',
66
+ data: {},
67
+ });
68
+ return await this.client.sendNotification(notification);
69
+ }
70
+
71
+ async sendNotification() {
72
+ const firstNotification = new Notification({
73
+ contents: {
74
+ en: 'Test notification',
75
+ tr: 'Test mesajı',
76
+ bg: 'Съобщение за проба',
77
+ },
78
+ });
79
+ firstNotification.setTargetDevices([
80
+ 'b188dd55-7c70-4072-b696-8b66a56f9c4c',
81
+ ]);
82
+ firstNotification.setParameter('data', { abc: '123', foo: 'bar' });
83
+ return await this.client.sendNotification(firstNotification);
84
+ }
80
85
  }
81
-
82
86
  ```
83
87
 
84
88
  ##### Then use it inside your Gapi Application for example inside Effects:
85
89
 
86
90
  ```typescript
87
-
88
91
  import { OfType, Effect } from '@rxdi/core';
89
92
  import { GapiPubSubService } from '@gapi/core';
90
93
  import { EffectTypes } from '../core/api-introspection/EffectTypes';
@@ -92,17 +95,14 @@ import { NotificationService } from '../core/services/notification/notification.
92
95
 
93
96
  @Effect()
94
97
  export class YourCustomEffects {
98
+ constructor(private notificationService: NotificationService) {}
95
99
 
96
- constructor(
97
- private notificationService: NotificationService
98
- ) {}
99
-
100
- @OfType<EffectTypes>(EffectTypes.myevent)
101
- async myEventTrigger(result, {payload}, context) {
102
- await this.notificationService.createNotification(result);
103
- }
100
+ @OfType<EffectTypes>(EffectTypes.myevent)
101
+ async myEventTrigger(result, { payload }, context) {
102
+ await this.notificationService.createNotification(result);
103
+ }
104
104
  }
105
105
  ```
106
106
 
107
- More detailed [DOCUMENTATION](https://github.com/KolektifLabs/onesignal-node) you can find inside original onesignal-node module
108
- Enjoy ! :)
107
+ More detailed [DOCUMENTATION](https://github.com/KolektifLabs/onesignal-node) you can find inside original onesignal-node module
108
+ Enjoy ! :)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gapi/onesignal-notifications",
3
- "version": "1.8.151",
3
+ "version": "1.8.153",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Stradivario/onesignal-notifications.git"
@@ -9,6 +9,7 @@
9
9
  "patch": "npm run build && npm version patch && npm publish --update-readme --access public && npm run delete-dist",
10
10
  "delete-dist": "rm -rf dist",
11
11
  "clean": "git clean -dxf",
12
+ "test": "echo test",
12
13
  "lint": "npx eslint . --ext .ts",
13
14
  "lint-fix": "npx eslint . --fix --ext .ts",
14
15
  "build": "rm -rf dist && tsc || true"
@@ -24,13 +25,13 @@
24
25
  ],
25
26
  "license": "MIT",
26
27
  "bugs": {
27
- "url": "http://gitlab.youvolio.com/gapi/onesignal-notifications/issues"
28
+ "url": "https://github.com/Stradivario/gapi/issues"
28
29
  },
29
30
  "dependencies": {
30
31
  "request": "^2.88.0"
31
32
  },
32
33
  "devDependencies": {
33
- "@rxdi/core": "^0.7.173",
34
+ "@rxdi/core": "^0.7.182",
34
35
  "@types/node": "^13.11.1",
35
36
  "@types/request": "^2.48.1"
36
37
  },