@imatis/react-native-notifications 4.3.3-imatis.11 → 4.3.3-imatis.12

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 (61) hide show
  1. package/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +1 -1
  2. package/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +8 -3
  3. package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +3 -11
  4. package/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +2 -2
  5. package/lib/dist/DTO/Notification.d.ts +11 -0
  6. package/lib/dist/DTO/Notification.js +30 -0
  7. package/lib/dist/DTO/Notification.test.d.ts +1 -0
  8. package/lib/dist/DTO/Notification.test.js +52 -0
  9. package/lib/dist/DTO/NotificationAndroid.d.ts +7 -0
  10. package/lib/dist/DTO/NotificationAndroid.js +20 -0
  11. package/lib/dist/DTO/NotificationAndroid.test.d.ts +1 -0
  12. package/lib/dist/DTO/NotificationAndroid.test.js +25 -0
  13. package/lib/dist/DTO/NotificationFactory.d.ts +4 -0
  14. package/lib/dist/DTO/NotificationFactory.js +18 -0
  15. package/lib/dist/DTO/NotificationIOS.d.ts +12 -0
  16. package/lib/dist/DTO/NotificationIOS.js +41 -0
  17. package/lib/dist/DTO/NotificationIOS.test.d.ts +1 -0
  18. package/lib/dist/DTO/NotificationIOS.test.js +58 -0
  19. package/lib/dist/Notifications.d.ts +65 -0
  20. package/lib/dist/Notifications.js +108 -0
  21. package/lib/dist/NotificationsAndroid.d.ts +14 -0
  22. package/lib/dist/NotificationsAndroid.js +33 -0
  23. package/lib/dist/NotificationsIOS.d.ts +51 -0
  24. package/lib/dist/NotificationsIOS.js +85 -0
  25. package/lib/dist/adapters/CompletionCallbackWrapper.d.ts +11 -0
  26. package/lib/dist/adapters/CompletionCallbackWrapper.js +45 -0
  27. package/lib/dist/adapters/NativeCommandsSender.d.ts +31 -0
  28. package/lib/dist/adapters/NativeCommandsSender.js +74 -0
  29. package/lib/dist/adapters/NativeEventsReceiver.d.ts +19 -0
  30. package/lib/dist/adapters/NativeEventsReceiver.js +49 -0
  31. package/lib/dist/adapters/UniqueIdProvider.d.ts +3 -0
  32. package/lib/dist/adapters/UniqueIdProvider.js +10 -0
  33. package/lib/dist/commands/Commands.d.ts +32 -0
  34. package/lib/dist/commands/Commands.js +82 -0
  35. package/lib/dist/commands/Commands.test.d.ts +1 -0
  36. package/lib/dist/commands/Commands.test.js +201 -0
  37. package/lib/dist/events/EventsRegistry.d.ts +18 -0
  38. package/lib/dist/events/EventsRegistry.js +30 -0
  39. package/lib/dist/events/EventsRegistry.test.d.ts +1 -0
  40. package/lib/dist/events/EventsRegistry.test.js +183 -0
  41. package/lib/dist/events/EventsRegistryIOS.d.ts +12 -0
  42. package/lib/dist/events/EventsRegistryIOS.js +21 -0
  43. package/lib/dist/events/EventsRegistryIOS.test.d.ts +1 -0
  44. package/lib/dist/events/EventsRegistryIOS.test.js +53 -0
  45. package/lib/dist/index.d.ts +7 -0
  46. package/lib/dist/index.js +12 -0
  47. package/lib/dist/interfaces/EventSubscription.d.ts +3 -0
  48. package/lib/dist/interfaces/EventSubscription.js +2 -0
  49. package/lib/dist/interfaces/NotificationActionResponse.d.ts +5 -0
  50. package/lib/dist/interfaces/NotificationActionResponse.js +12 -0
  51. package/lib/dist/interfaces/NotificationCategory.d.ts +18 -0
  52. package/lib/dist/interfaces/NotificationCategory.js +27 -0
  53. package/lib/dist/interfaces/NotificationChannel.d.ts +14 -0
  54. package/lib/dist/interfaces/NotificationChannel.js +2 -0
  55. package/lib/dist/interfaces/NotificationCompletion.d.ts +10 -0
  56. package/lib/dist/interfaces/NotificationCompletion.js +9 -0
  57. package/lib/dist/interfaces/NotificationEvents.d.ts +18 -0
  58. package/lib/dist/interfaces/NotificationEvents.js +2 -0
  59. package/lib/dist/interfaces/NotificationPermissions.d.ts +14 -0
  60. package/lib/dist/interfaces/NotificationPermissions.js +2 -0
  61. package/package.json +1 -1
@@ -63,7 +63,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
63
63
  @Override
64
64
  public void onNewIntent(Intent intent) {
65
65
  if (NotificationIntentAdapter.canHandleIntent(intent)) {
66
- Bundle notificationData = intent.getExtras();
66
+ Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
67
67
  final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData);
68
68
  if (notification != null) {
69
69
  notification.onOpened();
@@ -19,6 +19,7 @@ import com.wix.reactnativenotifications.core.notification.IPushNotification;
19
19
  import com.wix.reactnativenotifications.core.notification.PushNotification;
20
20
  import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer;
21
21
  import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer;
22
+ import com.wix.reactnativenotifications.core.ReactAppLifecycleFacade;
22
23
 
23
24
  import java.util.Arrays;
24
25
  import java.util.Collections;
@@ -66,7 +67,12 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade.
66
67
 
67
68
  @Override
68
69
  public void onActivityStarted(Activity activity) {
69
- if (InitialNotificationHolder.getInstance().get() == null) {
70
+ boolean isReactInitialized = false;
71
+ if (AppLifecycleFacadeHolder.get() instanceof ReactAppLifecycleFacade) {
72
+ isReactInitialized = AppLifecycleFacadeHolder.get().isReactInitialized();
73
+ }
74
+
75
+ if (InitialNotificationHolder.getInstance().get() == null && !isReactInitialized) {
70
76
  callOnOpenedIfNeed(activity);
71
77
  }
72
78
  }
@@ -95,8 +101,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade.
95
101
  Intent intent = activity.getIntent();
96
102
  if (NotificationIntentAdapter.canHandleIntent(intent)) {
97
103
  Context appContext = mApplication.getApplicationContext();
98
- Bundle notificationData = NotificationIntentAdapter.canHandleTrampolineActivity(appContext) ?
99
- intent.getExtras() : NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
104
+ Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
100
105
  final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
101
106
  if (pushNotification != null) {
102
107
  pushNotification.onOpened();
@@ -14,17 +14,9 @@ public class NotificationIntentAdapter {
14
14
 
15
15
  @SuppressLint("UnspecifiedImmutableFlag")
16
16
  public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) {
17
- if (canHandleTrampolineActivity(appContext)) {
18
- Intent intent = new Intent(appContext, ProxyService.class);
19
- intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
20
- return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT);
21
- } else {
22
- Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
23
- mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
24
- TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext);
25
- taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent);
26
- return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
27
- }
17
+ Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
18
+ intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
19
+ return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
28
20
  }
29
21
 
30
22
  public static boolean canHandleTrampolineActivity(Context appContext) {
@@ -2,8 +2,8 @@
2
2
  package com.wix.reactnativenotifications;
3
3
 
4
4
  import android.content.Context;
5
- import android.support.annotation.NonNull;
6
- import android.support.v4.app.NotificationManagerCompat;
5
+ import androidx.annotation.NonNull;
6
+ import androidx.core.app.NotificationManagerCompat;
7
7
 
8
8
  public abstract class NotificationManagerCompatFacade {
9
9
  public static NotificationManagerCompat from(@NonNull Context context) {
@@ -0,0 +1,11 @@
1
+ export declare class Notification {
2
+ identifier: string;
3
+ payload: any;
4
+ constructor(payload: object);
5
+ get title(): string;
6
+ get body(): string;
7
+ get sound(): string;
8
+ get badge(): number;
9
+ get type(): string;
10
+ get thread(): string;
11
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Notification = void 0;
4
+ class Notification {
5
+ identifier;
6
+ payload;
7
+ constructor(payload) {
8
+ this.payload = payload;
9
+ this.identifier = this.payload.identifier;
10
+ }
11
+ get title() {
12
+ return this.payload.title;
13
+ }
14
+ get body() {
15
+ return this.payload.body;
16
+ }
17
+ get sound() {
18
+ return this.payload.sound;
19
+ }
20
+ get badge() {
21
+ return this.payload.badge;
22
+ }
23
+ get type() {
24
+ return this.payload.type;
25
+ }
26
+ get thread() {
27
+ return this.payload.thread;
28
+ }
29
+ }
30
+ exports.Notification = Notification;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Notification_1 = require("./Notification");
4
+ const NotificationIOS_1 = require("./NotificationIOS");
5
+ const NotificationAndroid_1 = require("./NotificationAndroid");
6
+ describe('Notification', () => {
7
+ it('Should create notification with payload', () => {
8
+ const payload = { p: 'p' };
9
+ const notification = new Notification_1.Notification(payload);
10
+ expect(notification.payload).toEqual(payload);
11
+ });
12
+ it('Should create iOS notification with identifier', () => {
13
+ const payload = { identifier: 'identifier' };
14
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
15
+ expect(notification.identifier).toEqual(payload.identifier);
16
+ });
17
+ it('Should create Android notification with identifier', () => {
18
+ const payload = { 'google.message_id': 'identifier' };
19
+ const notification = new NotificationAndroid_1.NotificationAndroid(payload);
20
+ expect(notification.identifier).toEqual('identifier');
21
+ });
22
+ it('Should return title from payload', () => {
23
+ const payload = { title: 'title' };
24
+ const notification = new Notification_1.Notification(payload);
25
+ expect(notification.title).toEqual(payload.title);
26
+ });
27
+ it('Should return body from payload', () => {
28
+ const payload = { body: 'body' };
29
+ const notification = new Notification_1.Notification(payload);
30
+ expect(notification.body).toEqual(payload.body);
31
+ });
32
+ it('Should return sound from payload', () => {
33
+ const payload = { sound: 'sound.mp4' };
34
+ const notification = new Notification_1.Notification(payload);
35
+ expect(notification.sound).toEqual(payload.sound);
36
+ });
37
+ it('Should return badge from payload', () => {
38
+ const payload = { badge: 1 };
39
+ const notification = new Notification_1.Notification(payload);
40
+ expect(notification.badge).toEqual(payload.badge);
41
+ });
42
+ it('Should return type from payload', () => {
43
+ const payload = { type: 'type' };
44
+ const notification = new Notification_1.Notification(payload);
45
+ expect(notification.type).toEqual(payload.type);
46
+ });
47
+ it('Should return thread from payload', () => {
48
+ const payload = { thread: 'thread' };
49
+ const notification = new Notification_1.Notification(payload);
50
+ expect(notification.thread).toEqual(payload.thread);
51
+ });
52
+ });
@@ -0,0 +1,7 @@
1
+ import { Notification } from './Notification';
2
+ export declare class NotificationAndroid extends Notification {
3
+ constructor(payload: object);
4
+ get title(): string;
5
+ get body(): string;
6
+ get sound(): string;
7
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationAndroid = void 0;
4
+ const Notification_1 = require("./Notification");
5
+ class NotificationAndroid extends Notification_1.Notification {
6
+ constructor(payload) {
7
+ super(payload);
8
+ this.identifier = this.payload["google.message_id"];
9
+ }
10
+ get title() {
11
+ return this.payload.title;
12
+ }
13
+ get body() {
14
+ return this.payload.body;
15
+ }
16
+ get sound() {
17
+ return this.payload.sound;
18
+ }
19
+ }
20
+ exports.NotificationAndroid = NotificationAndroid;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const NotificationAndroid_1 = require("./NotificationAndroid");
4
+ describe('Notification', () => {
5
+ it('Should create notification with payload', () => {
6
+ const payload = { p: 'p' };
7
+ const notification = new NotificationAndroid_1.NotificationAndroid(payload);
8
+ expect(notification.payload).toEqual(payload);
9
+ });
10
+ it('Should return title from payload', () => {
11
+ const payload = { title: 'title', body: 'body' };
12
+ const notification = new NotificationAndroid_1.NotificationAndroid(payload);
13
+ expect(notification.title).toEqual('title');
14
+ });
15
+ it('Should return body from payload', () => {
16
+ const payload = { title: 'title', body: 'body' };
17
+ const notification = new NotificationAndroid_1.NotificationAndroid(payload);
18
+ expect(notification.body).toEqual('body');
19
+ });
20
+ it('Should return sound from payload', () => {
21
+ const payload = { title: 'title', sound: 'sound.wav' };
22
+ const notification = new NotificationAndroid_1.NotificationAndroid(payload);
23
+ expect(notification.sound).toEqual('sound.wav');
24
+ });
25
+ });
@@ -0,0 +1,4 @@
1
+ import { Notification } from './Notification';
2
+ export declare class NotificationFactory {
3
+ fromPayload(payload: any): Notification;
4
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationFactory = void 0;
4
+ const Notification_1 = require("./Notification");
5
+ const NotificationIOS_1 = require("./NotificationIOS");
6
+ const NotificationAndroid_1 = require("./NotificationAndroid");
7
+ const react_native_1 = require("react-native");
8
+ class NotificationFactory {
9
+ fromPayload(payload) {
10
+ if (react_native_1.Platform.OS === 'ios') {
11
+ return payload.aps ? new NotificationIOS_1.NotificationIOS(payload) : new Notification_1.Notification(payload);
12
+ }
13
+ else {
14
+ return new NotificationAndroid_1.NotificationAndroid(payload);
15
+ }
16
+ }
17
+ }
18
+ exports.NotificationFactory = NotificationFactory;
@@ -0,0 +1,12 @@
1
+ import { Notification } from './Notification';
2
+ export declare class NotificationIOS extends Notification {
3
+ identifier: string;
4
+ constructor(payload: object);
5
+ get aps(): any;
6
+ get alert(): any;
7
+ get title(): string;
8
+ get body(): string;
9
+ get sound(): string;
10
+ get badge(): number;
11
+ get thread(): string;
12
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationIOS = void 0;
4
+ const Notification_1 = require("./Notification");
5
+ const _ = require("lodash");
6
+ class NotificationIOS extends Notification_1.Notification {
7
+ identifier;
8
+ constructor(payload) {
9
+ super(payload);
10
+ this.identifier = this.payload.identifier;
11
+ }
12
+ get aps() {
13
+ return this.payload.aps || {};
14
+ }
15
+ get alert() {
16
+ if (_.isObject(this.aps.alert)) {
17
+ return this.aps.alert;
18
+ }
19
+ else if (_.isString(this.aps.alert)) {
20
+ return {
21
+ body: this.aps.alert
22
+ };
23
+ }
24
+ }
25
+ get title() {
26
+ return this.alert.title;
27
+ }
28
+ get body() {
29
+ return this.alert.body;
30
+ }
31
+ get sound() {
32
+ return this.aps.sound;
33
+ }
34
+ get badge() {
35
+ return this.aps.badge;
36
+ }
37
+ get thread() {
38
+ return this.aps.thread;
39
+ }
40
+ }
41
+ exports.NotificationIOS = NotificationIOS;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const NotificationIOS_1 = require("./NotificationIOS");
4
+ describe('Notification', () => {
5
+ it('Should create notification with payload', () => {
6
+ const payload = { p: 'p' };
7
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
8
+ expect(notification.payload).toEqual(payload);
9
+ });
10
+ it('Should create notification with valid aps', () => {
11
+ const aps = { alert: {} };
12
+ const payload = { aps };
13
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
14
+ expect(notification.aps).toEqual(aps);
15
+ });
16
+ it('Should create notification with empy aps', () => {
17
+ const payload = { aps: undefined };
18
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
19
+ expect(notification.aps).toEqual({});
20
+ });
21
+ it('Should return alert object', () => {
22
+ const payload = { aps: { alert: { title: 'title' } } };
23
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
24
+ expect(notification.alert).toEqual(payload.aps.alert);
25
+ });
26
+ it('Should return alert object when alert is string', () => {
27
+ const payload = { aps: { alert: 'title' } };
28
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
29
+ expect(notification.alert).toEqual({
30
+ body: 'title'
31
+ });
32
+ });
33
+ it('Should return title from alert', () => {
34
+ const payload = { aps: { alert: { title: 'title' } } };
35
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
36
+ expect(notification.title).toEqual('title');
37
+ });
38
+ it('Should return body from alert', () => {
39
+ const payload = { aps: { alert: { title: 'title', body: 'body' } } };
40
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
41
+ expect(notification.body).toEqual('body');
42
+ });
43
+ it('Should return badge from aps', () => {
44
+ const payload = { aps: { badge: 0 } };
45
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
46
+ expect(notification.badge).toEqual(0);
47
+ });
48
+ it('Should return sound from aps', () => {
49
+ const payload = { aps: { sound: 'sound.wav' } };
50
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
51
+ expect(notification.sound).toEqual('sound.wav');
52
+ });
53
+ it('Should return thread from aps', () => {
54
+ const payload = { aps: { thread: 'thread' } };
55
+ const notification = new NotificationIOS_1.NotificationIOS(payload);
56
+ expect(notification.thread).toEqual('thread');
57
+ });
58
+ });
@@ -0,0 +1,65 @@
1
+ import { EventsRegistry } from './events/EventsRegistry';
2
+ import { Notification } from './DTO/Notification';
3
+ import { NotificationCategory } from './interfaces/NotificationCategory';
4
+ import { NotificationChannel } from './interfaces/NotificationChannel';
5
+ import { NotificationsIOS } from './NotificationsIOS';
6
+ import { NotificationsAndroid } from './NotificationsAndroid';
7
+ import { NotificationPermissionOptions } from './interfaces/NotificationPermissions';
8
+ export declare class NotificationsRoot {
9
+ readonly _ios: NotificationsIOS;
10
+ readonly _android: NotificationsAndroid;
11
+ private readonly notificationFactory;
12
+ private readonly nativeEventsReceiver;
13
+ private readonly nativeCommandsSender;
14
+ private readonly commands;
15
+ private readonly eventsRegistry;
16
+ private readonly eventsRegistryIOS;
17
+ private readonly uniqueIdProvider;
18
+ private readonly completionCallbackWrapper;
19
+ constructor();
20
+ /**
21
+ * registerRemoteNotifications
22
+ */
23
+ registerRemoteNotifications(options?: NotificationPermissionOptions): void;
24
+ /**
25
+ * postLocalNotification
26
+ */
27
+ postLocalNotification(notification: Notification, id?: number): number;
28
+ /**
29
+ * getInitialNotification
30
+ */
31
+ getInitialNotification(): Promise<Notification | undefined>;
32
+ /**
33
+ * getLastAction
34
+ */
35
+ getLastAction(): Promise<Notification | undefined>;
36
+ /**
37
+ * setCategories
38
+ */
39
+ setCategories(categories: [NotificationCategory?]): void;
40
+ /**
41
+ * cancelLocalNotification
42
+ */
43
+ cancelLocalNotification(notificationId: number): void;
44
+ /**
45
+ * removeAllDeliveredNotifications
46
+ */
47
+ removeAllDeliveredNotifications(): void;
48
+ /**
49
+ * isRegisteredForRemoteNotifications
50
+ */
51
+ isRegisteredForRemoteNotifications(): Promise<boolean>;
52
+ /**
53
+ * setNotificationChannel
54
+ */
55
+ setNotificationChannel(notificationChannel: NotificationChannel): void;
56
+ /**
57
+ * Obtain the events registry instance
58
+ */
59
+ events(): EventsRegistry;
60
+ /**
61
+ * ios/android getters
62
+ */
63
+ get ios(): NotificationsIOS;
64
+ get android(): NotificationsAndroid;
65
+ }
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationsRoot = void 0;
4
+ const NativeCommandsSender_1 = require("./adapters/NativeCommandsSender");
5
+ const NativeEventsReceiver_1 = require("./adapters/NativeEventsReceiver");
6
+ const Commands_1 = require("./commands/Commands");
7
+ const EventsRegistry_1 = require("./events/EventsRegistry");
8
+ const EventsRegistryIOS_1 = require("./events/EventsRegistryIOS");
9
+ const UniqueIdProvider_1 = require("./adapters/UniqueIdProvider");
10
+ const CompletionCallbackWrapper_1 = require("./adapters/CompletionCallbackWrapper");
11
+ const NotificationsIOS_1 = require("./NotificationsIOS");
12
+ const NotificationsAndroid_1 = require("./NotificationsAndroid");
13
+ const NotificationFactory_1 = require("./DTO/NotificationFactory");
14
+ class NotificationsRoot {
15
+ _ios;
16
+ _android;
17
+ notificationFactory;
18
+ nativeEventsReceiver;
19
+ nativeCommandsSender;
20
+ commands;
21
+ eventsRegistry;
22
+ eventsRegistryIOS;
23
+ uniqueIdProvider;
24
+ completionCallbackWrapper;
25
+ constructor() {
26
+ this.notificationFactory = new NotificationFactory_1.NotificationFactory();
27
+ this.nativeEventsReceiver = new NativeEventsReceiver_1.NativeEventsReceiver(this.notificationFactory);
28
+ this.nativeCommandsSender = new NativeCommandsSender_1.NativeCommandsSender();
29
+ this.completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(this.nativeCommandsSender);
30
+ this.uniqueIdProvider = new UniqueIdProvider_1.UniqueIdProvider();
31
+ this.commands = new Commands_1.Commands(this.nativeCommandsSender, this.uniqueIdProvider, this.notificationFactory);
32
+ this.eventsRegistry = new EventsRegistry_1.EventsRegistry(this.nativeEventsReceiver, this.completionCallbackWrapper);
33
+ this.eventsRegistryIOS = new EventsRegistryIOS_1.EventsRegistryIOS(this.nativeEventsReceiver, this.completionCallbackWrapper);
34
+ this._ios = new NotificationsIOS_1.NotificationsIOS(this.commands, this.eventsRegistryIOS);
35
+ this._android = new NotificationsAndroid_1.NotificationsAndroid(this.commands);
36
+ }
37
+ /**
38
+ * registerRemoteNotifications
39
+ */
40
+ registerRemoteNotifications(options) {
41
+ this.ios.registerRemoteNotifications(options);
42
+ this.android.registerRemoteNotifications();
43
+ }
44
+ /**
45
+ * postLocalNotification
46
+ */
47
+ postLocalNotification(notification, id) {
48
+ return this.commands.postLocalNotification(notification, id);
49
+ }
50
+ /**
51
+ * getInitialNotification
52
+ */
53
+ getInitialNotification() {
54
+ return this.commands.getInitialNotification();
55
+ }
56
+ /**
57
+ * getLastAction
58
+ */
59
+ getLastAction() {
60
+ return this.commands.getLastAction();
61
+ }
62
+ /**
63
+ * setCategories
64
+ */
65
+ setCategories(categories) {
66
+ this.commands.setCategories(categories);
67
+ }
68
+ /**
69
+ * cancelLocalNotification
70
+ */
71
+ cancelLocalNotification(notificationId) {
72
+ return this.commands.cancelLocalNotification(notificationId);
73
+ }
74
+ /**
75
+ * removeAllDeliveredNotifications
76
+ */
77
+ removeAllDeliveredNotifications() {
78
+ return this.commands.removeAllDeliveredNotifications();
79
+ }
80
+ /**
81
+ * isRegisteredForRemoteNotifications
82
+ */
83
+ isRegisteredForRemoteNotifications() {
84
+ return this.commands.isRegisteredForRemoteNotifications();
85
+ }
86
+ /**
87
+ * setNotificationChannel
88
+ */
89
+ setNotificationChannel(notificationChannel) {
90
+ return this.android.setNotificationChannel(notificationChannel);
91
+ }
92
+ /**
93
+ * Obtain the events registry instance
94
+ */
95
+ events() {
96
+ return this.eventsRegistry;
97
+ }
98
+ /**
99
+ * ios/android getters
100
+ */
101
+ get ios() {
102
+ return this._ios;
103
+ }
104
+ get android() {
105
+ return this._android;
106
+ }
107
+ }
108
+ exports.NotificationsRoot = NotificationsRoot;
@@ -0,0 +1,14 @@
1
+ import { Commands } from './commands/Commands';
2
+ import { NotificationChannel } from './interfaces/NotificationChannel';
3
+ export declare class NotificationsAndroid {
4
+ private readonly commands;
5
+ constructor(commands: Commands);
6
+ /**
7
+ * Refresh FCM token
8
+ */
9
+ registerRemoteNotifications(): void;
10
+ /**
11
+ * setNotificationChannel
12
+ */
13
+ setNotificationChannel(notificationChannel: NotificationChannel): void;
14
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotificationsAndroid = void 0;
4
+ const react_native_1 = require("react-native");
5
+ class NotificationsAndroid {
6
+ commands;
7
+ constructor(commands) {
8
+ this.commands = commands;
9
+ return new Proxy(this, {
10
+ get(target, name) {
11
+ if (react_native_1.Platform.OS === 'android') {
12
+ return target[name];
13
+ }
14
+ else {
15
+ return () => { };
16
+ }
17
+ }
18
+ });
19
+ }
20
+ /**
21
+ * Refresh FCM token
22
+ */
23
+ registerRemoteNotifications() {
24
+ this.commands.refreshToken();
25
+ }
26
+ /**
27
+ * setNotificationChannel
28
+ */
29
+ setNotificationChannel(notificationChannel) {
30
+ return this.commands.setNotificationChannel(notificationChannel);
31
+ }
32
+ }
33
+ exports.NotificationsAndroid = NotificationsAndroid;
@@ -0,0 +1,51 @@
1
+ import { Notification } from './DTO/Notification';
2
+ import { Commands } from './commands/Commands';
3
+ import { EventsRegistryIOS } from './events/EventsRegistryIOS';
4
+ import { NotificationPermissionOptions } from './interfaces/NotificationPermissions';
5
+ export declare class NotificationsIOS {
6
+ private readonly commands;
7
+ private readonly eventsRegistry;
8
+ constructor(commands: Commands, eventsRegistry: EventsRegistryIOS);
9
+ /**
10
+ * Request permissions to send remote notifications
11
+ */
12
+ registerRemoteNotifications(options?: NotificationPermissionOptions): void;
13
+ /**
14
+ * Unregister for all remote notifications received via Apple Push Notification service
15
+ */
16
+ abandonPermissions(): void;
17
+ /**
18
+ * registerPushKit
19
+ */
20
+ registerPushKit(): void;
21
+ /**
22
+ * getBadgeCount
23
+ */
24
+ getBadgeCount(): Promise<number>;
25
+ /**
26
+ * setBadgeCount
27
+ * @param count number of the new badge count
28
+ */
29
+ setBadgeCount(count: number): void;
30
+ /**
31
+ * cancelAllLocalNotifications
32
+ */
33
+ cancelAllLocalNotifications(): void;
34
+ /**
35
+ * checkPermissions
36
+ */
37
+ checkPermissions(): Promise<import("./interfaces/NotificationPermissions").NotificationPermissions>;
38
+ /**
39
+ * removeDeliveredNotifications
40
+ * @param identifiers Array of notification identifiers
41
+ */
42
+ removeDeliveredNotifications(identifiers: Array<string>): void;
43
+ /**
44
+ * getDeliveredNotifications
45
+ */
46
+ getDeliveredNotifications(): Promise<Notification[]>;
47
+ /**
48
+ * Obtain the events registry instance
49
+ */
50
+ events(): EventsRegistryIOS;
51
+ }