@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.
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +1 -1
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +8 -3
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +3 -11
- package/lib/android/app/src/reactNative59/java/com/wix/reactnativenotifications/NotificationManagerCompatFacade.java +2 -2
- package/lib/dist/DTO/Notification.d.ts +11 -0
- package/lib/dist/DTO/Notification.js +30 -0
- package/lib/dist/DTO/Notification.test.d.ts +1 -0
- package/lib/dist/DTO/Notification.test.js +52 -0
- package/lib/dist/DTO/NotificationAndroid.d.ts +7 -0
- package/lib/dist/DTO/NotificationAndroid.js +20 -0
- package/lib/dist/DTO/NotificationAndroid.test.d.ts +1 -0
- package/lib/dist/DTO/NotificationAndroid.test.js +25 -0
- package/lib/dist/DTO/NotificationFactory.d.ts +4 -0
- package/lib/dist/DTO/NotificationFactory.js +18 -0
- package/lib/dist/DTO/NotificationIOS.d.ts +12 -0
- package/lib/dist/DTO/NotificationIOS.js +41 -0
- package/lib/dist/DTO/NotificationIOS.test.d.ts +1 -0
- package/lib/dist/DTO/NotificationIOS.test.js +58 -0
- package/lib/dist/Notifications.d.ts +65 -0
- package/lib/dist/Notifications.js +108 -0
- package/lib/dist/NotificationsAndroid.d.ts +14 -0
- package/lib/dist/NotificationsAndroid.js +33 -0
- package/lib/dist/NotificationsIOS.d.ts +51 -0
- package/lib/dist/NotificationsIOS.js +85 -0
- package/lib/dist/adapters/CompletionCallbackWrapper.d.ts +11 -0
- package/lib/dist/adapters/CompletionCallbackWrapper.js +45 -0
- package/lib/dist/adapters/NativeCommandsSender.d.ts +31 -0
- package/lib/dist/adapters/NativeCommandsSender.js +74 -0
- package/lib/dist/adapters/NativeEventsReceiver.d.ts +19 -0
- package/lib/dist/adapters/NativeEventsReceiver.js +49 -0
- package/lib/dist/adapters/UniqueIdProvider.d.ts +3 -0
- package/lib/dist/adapters/UniqueIdProvider.js +10 -0
- package/lib/dist/commands/Commands.d.ts +32 -0
- package/lib/dist/commands/Commands.js +82 -0
- package/lib/dist/commands/Commands.test.d.ts +1 -0
- package/lib/dist/commands/Commands.test.js +201 -0
- package/lib/dist/events/EventsRegistry.d.ts +18 -0
- package/lib/dist/events/EventsRegistry.js +30 -0
- package/lib/dist/events/EventsRegistry.test.d.ts +1 -0
- package/lib/dist/events/EventsRegistry.test.js +183 -0
- package/lib/dist/events/EventsRegistryIOS.d.ts +12 -0
- package/lib/dist/events/EventsRegistryIOS.js +21 -0
- package/lib/dist/events/EventsRegistryIOS.test.d.ts +1 -0
- package/lib/dist/events/EventsRegistryIOS.test.js +53 -0
- package/lib/dist/index.d.ts +7 -0
- package/lib/dist/index.js +12 -0
- package/lib/dist/interfaces/EventSubscription.d.ts +3 -0
- package/lib/dist/interfaces/EventSubscription.js +2 -0
- package/lib/dist/interfaces/NotificationActionResponse.d.ts +5 -0
- package/lib/dist/interfaces/NotificationActionResponse.js +12 -0
- package/lib/dist/interfaces/NotificationCategory.d.ts +18 -0
- package/lib/dist/interfaces/NotificationCategory.js +27 -0
- package/lib/dist/interfaces/NotificationChannel.d.ts +14 -0
- package/lib/dist/interfaces/NotificationChannel.js +2 -0
- package/lib/dist/interfaces/NotificationCompletion.d.ts +10 -0
- package/lib/dist/interfaces/NotificationCompletion.js +9 -0
- package/lib/dist/interfaces/NotificationEvents.d.ts +18 -0
- package/lib/dist/interfaces/NotificationEvents.js +2 -0
- package/lib/dist/interfaces/NotificationPermissions.d.ts +14 -0
- package/lib/dist/interfaces/NotificationPermissions.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
|
|
3
|
+
import { Registered, RegistrationError } from '../interfaces/NotificationEvents';
|
|
4
|
+
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse';
|
|
5
|
+
import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper';
|
|
6
|
+
import { Notification } from '../DTO/Notification';
|
|
7
|
+
import { NotificationCompletion, NotificationBackgroundFetchResult } from '../interfaces/NotificationCompletion';
|
|
8
|
+
export declare class EventsRegistry {
|
|
9
|
+
private nativeEventsReceiver;
|
|
10
|
+
private completionCallbackWrapper;
|
|
11
|
+
constructor(nativeEventsReceiver: NativeEventsReceiver, completionCallbackWrapper: CompletionCallbackWrapper);
|
|
12
|
+
registerRemoteNotificationsRegistered(callback: (event: Registered) => void): EmitterSubscription;
|
|
13
|
+
registerNotificationReceivedForeground(callback: (notification: Notification, completion: (response: NotificationCompletion) => void) => void): EmitterSubscription;
|
|
14
|
+
registerNotificationReceivedBackground(callback: (notification: Notification, completion: (response: NotificationBackgroundFetchResult) => void) => void): EmitterSubscription;
|
|
15
|
+
registerNotificationOpened(callback: (notification: Notification, completion: () => void, actionResponse?: NotificationActionResponse) => void): EmitterSubscription;
|
|
16
|
+
registerRemoteNotificationsRegistrationFailed(callback: (event: RegistrationError) => void): EmitterSubscription;
|
|
17
|
+
registerRemoteNotificationsRegistrationDenied(callback: () => void): EmitterSubscription;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventsRegistry = void 0;
|
|
4
|
+
class EventsRegistry {
|
|
5
|
+
nativeEventsReceiver;
|
|
6
|
+
completionCallbackWrapper;
|
|
7
|
+
constructor(nativeEventsReceiver, completionCallbackWrapper) {
|
|
8
|
+
this.nativeEventsReceiver = nativeEventsReceiver;
|
|
9
|
+
this.completionCallbackWrapper = completionCallbackWrapper;
|
|
10
|
+
}
|
|
11
|
+
registerRemoteNotificationsRegistered(callback) {
|
|
12
|
+
return this.nativeEventsReceiver.registerRemoteNotificationsRegistered(callback);
|
|
13
|
+
}
|
|
14
|
+
registerNotificationReceivedForeground(callback) {
|
|
15
|
+
return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedForegroundCallback(callback));
|
|
16
|
+
}
|
|
17
|
+
registerNotificationReceivedBackground(callback) {
|
|
18
|
+
return this.nativeEventsReceiver.registerNotificationReceivedBackground(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback));
|
|
19
|
+
}
|
|
20
|
+
registerNotificationOpened(callback) {
|
|
21
|
+
return this.nativeEventsReceiver.registerNotificationOpened(this.completionCallbackWrapper.wrapOpenedCallback(callback));
|
|
22
|
+
}
|
|
23
|
+
registerRemoteNotificationsRegistrationFailed(callback) {
|
|
24
|
+
return this.nativeEventsReceiver.registerRemoteNotificationsRegistrationFailed(callback);
|
|
25
|
+
}
|
|
26
|
+
registerRemoteNotificationsRegistrationDenied(callback) {
|
|
27
|
+
return this.nativeEventsReceiver.registerRemoteNotificationsRegistrationDenied(callback);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.EventsRegistry = EventsRegistry;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_native_1 = require("react-native");
|
|
4
|
+
const Notification_1 = require("../DTO/Notification");
|
|
5
|
+
const CompletionCallbackWrapper_1 = require("../adapters/CompletionCallbackWrapper");
|
|
6
|
+
const NativeCommandsSender_1 = require("../adapters/NativeCommandsSender");
|
|
7
|
+
const NativeEventsReceiver_1 = require("../adapters/NativeEventsReceiver");
|
|
8
|
+
const NotificationCompletion_1 = require("../interfaces/NotificationCompletion");
|
|
9
|
+
const EventsRegistry_1 = require("./EventsRegistry");
|
|
10
|
+
jest.mock('../adapters/NativeCommandsSender');
|
|
11
|
+
jest.mock('../adapters/NativeEventsReceiver');
|
|
12
|
+
describe('EventsRegistry', () => {
|
|
13
|
+
let uut;
|
|
14
|
+
const mockNativeEventsReceiver = new NativeEventsReceiver_1.NativeEventsReceiver();
|
|
15
|
+
const mockNativeCommandsSender = new NativeCommandsSender_1.NativeCommandsSender();
|
|
16
|
+
const completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(mockNativeCommandsSender);
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
uut = new EventsRegistry_1.EventsRegistry(mockNativeEventsReceiver, completionCallbackWrapper);
|
|
19
|
+
});
|
|
20
|
+
describe('registerRemoteNotificationsReceivedForeground', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
react_native_1.AppState.currentState = 'active';
|
|
23
|
+
});
|
|
24
|
+
it('delegates to nativeEventsReceiver', () => {
|
|
25
|
+
const cb = jest.fn();
|
|
26
|
+
uut.registerNotificationReceivedForeground(cb);
|
|
27
|
+
expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledTimes(1);
|
|
28
|
+
expect(mockNativeEventsReceiver.registerNotificationReceived).toHaveBeenCalledWith(expect.any(Function));
|
|
29
|
+
});
|
|
30
|
+
it('should wrap callback with completion block', () => {
|
|
31
|
+
const wrappedCallback = jest.fn();
|
|
32
|
+
const notification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
33
|
+
uut.registerNotificationReceivedForeground(wrappedCallback);
|
|
34
|
+
const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0];
|
|
35
|
+
call(notification);
|
|
36
|
+
expect(wrappedCallback).toBeCalledWith(notification, expect.any(Function));
|
|
37
|
+
expect(wrappedCallback).toBeCalledTimes(1);
|
|
38
|
+
});
|
|
39
|
+
it('should wrap callback with completion block', () => {
|
|
40
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
41
|
+
uut.registerNotificationReceivedForeground((notification) => {
|
|
42
|
+
expect(notification).toEqual(expectedNotification);
|
|
43
|
+
});
|
|
44
|
+
const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0];
|
|
45
|
+
call(expectedNotification);
|
|
46
|
+
});
|
|
47
|
+
it('should invoke finishPresentingNotification', () => {
|
|
48
|
+
const notification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
49
|
+
const response = { alert: true };
|
|
50
|
+
uut.registerNotificationReceivedForeground((notification, completion) => {
|
|
51
|
+
completion(response);
|
|
52
|
+
expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledWith(notification.identifier, response);
|
|
53
|
+
});
|
|
54
|
+
const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0];
|
|
55
|
+
call(notification);
|
|
56
|
+
});
|
|
57
|
+
it('should not invoke finishPresentingNotification on Android', () => {
|
|
58
|
+
react_native_1.Platform.OS = 'android';
|
|
59
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
60
|
+
const response = { alert: true };
|
|
61
|
+
uut.registerNotificationReceivedForeground((notification, completion) => {
|
|
62
|
+
completion(response);
|
|
63
|
+
expect(expectedNotification).toEqual(notification);
|
|
64
|
+
expect(mockNativeCommandsSender.finishPresentingNotification).toBeCalledTimes(0);
|
|
65
|
+
});
|
|
66
|
+
const call = mockNativeEventsReceiver.registerNotificationReceived.mock.calls[0][0];
|
|
67
|
+
call(expectedNotification);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('registerRemoteNotificationsReceivedBackground', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
react_native_1.AppState.currentState = 'background';
|
|
73
|
+
});
|
|
74
|
+
it('delegates to nativeEventsReceiver', () => {
|
|
75
|
+
const cb = jest.fn();
|
|
76
|
+
uut.registerNotificationReceivedBackground(cb);
|
|
77
|
+
expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledTimes(1);
|
|
78
|
+
expect(mockNativeEventsReceiver.registerNotificationReceivedBackground).toHaveBeenCalledWith(expect.any(Function));
|
|
79
|
+
});
|
|
80
|
+
it('should wrap callback with completion block', () => {
|
|
81
|
+
const wrappedCallback = jest.fn();
|
|
82
|
+
const notification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
83
|
+
uut.registerNotificationReceivedBackground(wrappedCallback);
|
|
84
|
+
const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0];
|
|
85
|
+
call(notification);
|
|
86
|
+
expect(wrappedCallback).toBeCalledWith(notification, expect.any(Function));
|
|
87
|
+
expect(wrappedCallback).toBeCalledTimes(1);
|
|
88
|
+
});
|
|
89
|
+
it('should wrap callback with completion block', () => {
|
|
90
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
91
|
+
uut.registerNotificationReceivedBackground((notification) => {
|
|
92
|
+
expect(notification).toEqual(expectedNotification);
|
|
93
|
+
});
|
|
94
|
+
const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0];
|
|
95
|
+
call(expectedNotification);
|
|
96
|
+
});
|
|
97
|
+
it('should invoke finishHandlingBackgroundAction', () => {
|
|
98
|
+
const notification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
99
|
+
const response = NotificationCompletion_1.NotificationBackgroundFetchResult.NO_DATA;
|
|
100
|
+
uut.registerNotificationReceivedBackground((notification, completion) => {
|
|
101
|
+
completion(response);
|
|
102
|
+
expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledWith(notification.identifier, response);
|
|
103
|
+
});
|
|
104
|
+
const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0];
|
|
105
|
+
call(notification);
|
|
106
|
+
});
|
|
107
|
+
it('should not invoke finishHandlingBackgroundAction on Android', () => {
|
|
108
|
+
react_native_1.Platform.OS = 'android';
|
|
109
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
110
|
+
const response = NotificationCompletion_1.NotificationBackgroundFetchResult.NO_DATA;
|
|
111
|
+
uut.registerNotificationReceivedBackground((notification, completion) => {
|
|
112
|
+
completion(response);
|
|
113
|
+
expect(expectedNotification).toEqual(notification);
|
|
114
|
+
expect(mockNativeCommandsSender.finishHandlingBackgroundAction).toBeCalledTimes(0);
|
|
115
|
+
});
|
|
116
|
+
const call = mockNativeEventsReceiver.registerNotificationReceivedBackground.mock.calls[0][0];
|
|
117
|
+
call(expectedNotification);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe('', () => {
|
|
121
|
+
it('delegates to nativeEventsReceiver', () => {
|
|
122
|
+
const cb = jest.fn();
|
|
123
|
+
uut.registerNotificationOpened(cb);
|
|
124
|
+
expect(mockNativeEventsReceiver.registerNotificationOpened).toHaveBeenCalledTimes(1);
|
|
125
|
+
expect(mockNativeEventsReceiver.registerNotificationOpened).toHaveBeenCalledWith(expect.any(Function));
|
|
126
|
+
});
|
|
127
|
+
it('should wrap callback with completion block', () => {
|
|
128
|
+
const wrappedCallback = jest.fn();
|
|
129
|
+
const notification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
130
|
+
const response = {
|
|
131
|
+
notification,
|
|
132
|
+
identifier: 'responseId',
|
|
133
|
+
action: { identifier: 'actionIdentifier', text: 'userText' },
|
|
134
|
+
};
|
|
135
|
+
uut.registerNotificationOpened(wrappedCallback);
|
|
136
|
+
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
|
|
137
|
+
call(response.notification, response.action);
|
|
138
|
+
expect(wrappedCallback).toBeCalledWith(response.notification, expect.any(Function), response.action);
|
|
139
|
+
expect(wrappedCallback).toBeCalledTimes(1);
|
|
140
|
+
});
|
|
141
|
+
it('should wrap callback with completion block', () => {
|
|
142
|
+
const notification = new Notification_1.Notification({ identifier: 'identifier' });
|
|
143
|
+
uut.registerNotificationOpened((response) => {
|
|
144
|
+
expect(response).toEqual(notification);
|
|
145
|
+
});
|
|
146
|
+
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
|
|
147
|
+
call(notification);
|
|
148
|
+
});
|
|
149
|
+
it('calling completion should invoke finishHandlingAction', () => {
|
|
150
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
151
|
+
uut.registerNotificationOpened((notification, completion) => {
|
|
152
|
+
completion();
|
|
153
|
+
expect(expectedNotification).toEqual(notification);
|
|
154
|
+
expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledWith(notification.identifier);
|
|
155
|
+
});
|
|
156
|
+
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
|
|
157
|
+
call(expectedNotification);
|
|
158
|
+
});
|
|
159
|
+
it('should not invoke finishHandlingAction on Android', () => {
|
|
160
|
+
react_native_1.Platform.OS = 'android';
|
|
161
|
+
const expectedNotification = new Notification_1.Notification({ identifier: 'notificationId' });
|
|
162
|
+
uut.registerNotificationOpened((notification, completion) => {
|
|
163
|
+
completion();
|
|
164
|
+
expect(expectedNotification).toEqual(notification);
|
|
165
|
+
expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledTimes(0);
|
|
166
|
+
});
|
|
167
|
+
const call = mockNativeEventsReceiver.registerNotificationOpened.mock.calls[0][0];
|
|
168
|
+
call(expectedNotification);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
it('delegates registerRemoteNotificationsRegistered to nativeEventsReceiver', () => {
|
|
172
|
+
const cb = jest.fn();
|
|
173
|
+
uut.registerRemoteNotificationsRegistered(cb);
|
|
174
|
+
expect(mockNativeEventsReceiver.registerRemoteNotificationsRegistered).toHaveBeenCalledTimes(1);
|
|
175
|
+
expect(mockNativeEventsReceiver.registerRemoteNotificationsRegistered).toHaveBeenCalledWith(cb);
|
|
176
|
+
});
|
|
177
|
+
it('delegates registerRemoteNotificationsRegistrationFailed to nativeEventsReceiver', () => {
|
|
178
|
+
const cb = jest.fn();
|
|
179
|
+
uut.registerRemoteNotificationsRegistrationFailed(cb);
|
|
180
|
+
expect(mockNativeEventsReceiver.registerRemoteNotificationsRegistrationFailed).toHaveBeenCalledTimes(1);
|
|
181
|
+
expect(mockNativeEventsReceiver.registerRemoteNotificationsRegistrationFailed).toHaveBeenCalledWith(cb);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
|
|
3
|
+
import { RegisteredPushKit } from '../interfaces/NotificationEvents';
|
|
4
|
+
import { CompletionCallbackWrapper } from '../adapters/CompletionCallbackWrapper';
|
|
5
|
+
export declare class EventsRegistryIOS {
|
|
6
|
+
private nativeEventsReceiver;
|
|
7
|
+
private completionCallbackWrapper;
|
|
8
|
+
constructor(nativeEventsReceiver: NativeEventsReceiver, completionCallbackWrapper: CompletionCallbackWrapper);
|
|
9
|
+
registerPushKitRegistered(callback: (event: RegisteredPushKit) => void): EmitterSubscription;
|
|
10
|
+
registerPushKitNotificationReceived(callback: (event: object, completion: () => void) => void): EmitterSubscription;
|
|
11
|
+
appNotificationSettingsLinked(callback: () => void): EmitterSubscription;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventsRegistryIOS = void 0;
|
|
4
|
+
class EventsRegistryIOS {
|
|
5
|
+
nativeEventsReceiver;
|
|
6
|
+
completionCallbackWrapper;
|
|
7
|
+
constructor(nativeEventsReceiver, completionCallbackWrapper) {
|
|
8
|
+
this.nativeEventsReceiver = nativeEventsReceiver;
|
|
9
|
+
this.completionCallbackWrapper = completionCallbackWrapper;
|
|
10
|
+
}
|
|
11
|
+
registerPushKitRegistered(callback) {
|
|
12
|
+
return this.nativeEventsReceiver.registerPushKitRegistered(callback);
|
|
13
|
+
}
|
|
14
|
+
registerPushKitNotificationReceived(callback) {
|
|
15
|
+
return this.nativeEventsReceiver.registerPushKitNotificationReceived(this.completionCallbackWrapper.wrapOpenedCallback(callback));
|
|
16
|
+
}
|
|
17
|
+
appNotificationSettingsLinked(callback) {
|
|
18
|
+
return this.nativeEventsReceiver.appNotificationSettingsLinked(callback);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.EventsRegistryIOS = EventsRegistryIOS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const EventsRegistryIOS_1 = require("./EventsRegistryIOS");
|
|
4
|
+
const CompletionCallbackWrapper_1 = require("../adapters/CompletionCallbackWrapper");
|
|
5
|
+
const NativeCommandsSender_1 = require("../adapters/NativeCommandsSender");
|
|
6
|
+
const NativeEventsReceiver_1 = require("../adapters/NativeEventsReceiver");
|
|
7
|
+
jest.mock('../adapters/NativeCommandsSender');
|
|
8
|
+
jest.mock('../adapters/NativeEventsReceiver');
|
|
9
|
+
describe('EventsRegistryIOS', () => {
|
|
10
|
+
let uut;
|
|
11
|
+
const mockNativeEventsReceiver = new NativeEventsReceiver_1.NativeEventsReceiver();
|
|
12
|
+
const mockNativeCommandsSender = new NativeCommandsSender_1.NativeCommandsSender();
|
|
13
|
+
const completionCallbackWrapper = new CompletionCallbackWrapper_1.CompletionCallbackWrapper(mockNativeCommandsSender);
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
uut = new EventsRegistryIOS_1.EventsRegistryIOS(mockNativeEventsReceiver, completionCallbackWrapper);
|
|
16
|
+
});
|
|
17
|
+
it('delegates registerPushKitRegistered to nativeEventsReceiver', () => {
|
|
18
|
+
const cb = jest.fn();
|
|
19
|
+
uut.registerPushKitRegistered(cb);
|
|
20
|
+
expect(mockNativeEventsReceiver.registerPushKitRegistered).toHaveBeenCalledTimes(1);
|
|
21
|
+
expect(mockNativeEventsReceiver.registerPushKitRegistered).toHaveBeenCalledWith(cb);
|
|
22
|
+
});
|
|
23
|
+
it('delegates registerPushKitNotificationReceived to nativeEventsReceiver', () => {
|
|
24
|
+
const cb = jest.fn();
|
|
25
|
+
uut.registerPushKitNotificationReceived(cb);
|
|
26
|
+
expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledTimes(1);
|
|
27
|
+
expect(mockNativeEventsReceiver.registerPushKitNotificationReceived).toHaveBeenCalledWith(expect.any(Function));
|
|
28
|
+
});
|
|
29
|
+
it('should wrap callback with completion block', () => {
|
|
30
|
+
const expectedNotification = { identifier: 'notificationId' };
|
|
31
|
+
uut.registerPushKitNotificationReceived((notification) => {
|
|
32
|
+
expect(notification).toEqual(expectedNotification);
|
|
33
|
+
});
|
|
34
|
+
const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0];
|
|
35
|
+
call(expectedNotification);
|
|
36
|
+
});
|
|
37
|
+
it('should invoke finishPresentingNotification', () => {
|
|
38
|
+
const expectedNotification = { identifier: 'notificationId' };
|
|
39
|
+
uut.registerPushKitNotificationReceived((notification, completion) => {
|
|
40
|
+
completion();
|
|
41
|
+
expect(notification).toEqual(expectedNotification);
|
|
42
|
+
expect(mockNativeCommandsSender.finishHandlingAction).toBeCalledWith('notificationId');
|
|
43
|
+
});
|
|
44
|
+
const call = mockNativeEventsReceiver.registerPushKitNotificationReceived.mock.calls[0][0];
|
|
45
|
+
call(expectedNotification);
|
|
46
|
+
});
|
|
47
|
+
it('delegates appNotificationSettingsLinked to nativeEventsReceiver', () => {
|
|
48
|
+
const cb = jest.fn();
|
|
49
|
+
uut.appNotificationSettingsLinked(cb);
|
|
50
|
+
expect(mockNativeEventsReceiver.appNotificationSettingsLinked).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(mockNativeEventsReceiver.appNotificationSettingsLinked).toHaveBeenCalledWith(cb);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NotificationsRoot } from './Notifications';
|
|
2
|
+
export declare const Notifications: NotificationsRoot;
|
|
3
|
+
export * from './interfaces/EventSubscription';
|
|
4
|
+
export * from './DTO/Notification';
|
|
5
|
+
export * from './interfaces/NotificationEvents';
|
|
6
|
+
export * from './interfaces/NotificationCategory';
|
|
7
|
+
export * from './interfaces/NotificationCompletion';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Notifications = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Notifications_1 = require("./Notifications");
|
|
6
|
+
const notificationsSingleton = new Notifications_1.NotificationsRoot();
|
|
7
|
+
exports.Notifications = notificationsSingleton;
|
|
8
|
+
tslib_1.__exportStar(require("./interfaces/EventSubscription"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./DTO/Notification"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./interfaces/NotificationEvents"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./interfaces/NotificationCategory"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./interfaces/NotificationCompletion"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationActionResponse = void 0;
|
|
4
|
+
class NotificationActionResponse {
|
|
5
|
+
identifier;
|
|
6
|
+
text;
|
|
7
|
+
constructor(response) {
|
|
8
|
+
this.identifier = response.identifier;
|
|
9
|
+
this.text = response.text;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.NotificationActionResponse = NotificationActionResponse;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class NotificationCategory {
|
|
2
|
+
identifier: string;
|
|
3
|
+
actions?: NotificationAction[];
|
|
4
|
+
constructor(identifier: string, actions?: NotificationAction[]);
|
|
5
|
+
}
|
|
6
|
+
export interface NotificationTextInput {
|
|
7
|
+
buttonTitle: string;
|
|
8
|
+
placeholder: string;
|
|
9
|
+
}
|
|
10
|
+
export type ActivationMode = 'background' | 'foreground' | 'authenticationRequired' | 'destructive';
|
|
11
|
+
export declare class NotificationAction {
|
|
12
|
+
identifier: string;
|
|
13
|
+
activationMode: ActivationMode;
|
|
14
|
+
title: string;
|
|
15
|
+
authenticationRequired: boolean;
|
|
16
|
+
textInput?: NotificationTextInput;
|
|
17
|
+
constructor(identifier: string, activationMode: ActivationMode, title: string, authenticationRequired: boolean, textInput?: NotificationTextInput);
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationAction = exports.NotificationCategory = void 0;
|
|
4
|
+
class NotificationCategory {
|
|
5
|
+
identifier;
|
|
6
|
+
actions;
|
|
7
|
+
constructor(identifier, actions) {
|
|
8
|
+
this.identifier = identifier;
|
|
9
|
+
this.actions = actions;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.NotificationCategory = NotificationCategory;
|
|
13
|
+
class NotificationAction {
|
|
14
|
+
identifier;
|
|
15
|
+
activationMode;
|
|
16
|
+
title;
|
|
17
|
+
authenticationRequired;
|
|
18
|
+
textInput;
|
|
19
|
+
constructor(identifier, activationMode, title, authenticationRequired, textInput) {
|
|
20
|
+
this.identifier = identifier;
|
|
21
|
+
this.activationMode = activationMode;
|
|
22
|
+
this.title = title;
|
|
23
|
+
this.authenticationRequired = authenticationRequired;
|
|
24
|
+
this.textInput = textInput;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.NotificationAction = NotificationAction;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface NotificationChannel {
|
|
2
|
+
channelId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
importance: -1000 | 0 | 1 | 2 | 3 | 4 | 5;
|
|
5
|
+
description?: string;
|
|
6
|
+
enableLights?: boolean;
|
|
7
|
+
enableVibration?: boolean;
|
|
8
|
+
groupId?: string;
|
|
9
|
+
groupName?: string;
|
|
10
|
+
lightColor?: string;
|
|
11
|
+
showBadge?: boolean;
|
|
12
|
+
soundFile?: string;
|
|
13
|
+
vibrationPattern?: number[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationBackgroundFetchResult = void 0;
|
|
4
|
+
var NotificationBackgroundFetchResult;
|
|
5
|
+
(function (NotificationBackgroundFetchResult) {
|
|
6
|
+
NotificationBackgroundFetchResult["NEW_DATA"] = "newData";
|
|
7
|
+
NotificationBackgroundFetchResult["NO_DATA"] = "noData";
|
|
8
|
+
NotificationBackgroundFetchResult["FAILED"] = "failed";
|
|
9
|
+
})(NotificationBackgroundFetchResult = exports.NotificationBackgroundFetchResult || (exports.NotificationBackgroundFetchResult = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Notification } from '../DTO/Notification';
|
|
2
|
+
import { NotificationActionResponse } from './NotificationActionResponse';
|
|
3
|
+
export interface Registered {
|
|
4
|
+
deviceToken: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RegistrationError {
|
|
7
|
+
code: string;
|
|
8
|
+
domain: string;
|
|
9
|
+
localizedDescription: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RegisteredPushKit {
|
|
12
|
+
pushKitToken: string;
|
|
13
|
+
}
|
|
14
|
+
export interface NotificationResponse {
|
|
15
|
+
identifier: string;
|
|
16
|
+
notification: Notification;
|
|
17
|
+
action?: NotificationActionResponse;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface NotificationPermissionOptions {
|
|
2
|
+
carPlay?: boolean;
|
|
3
|
+
criticalAlert?: boolean;
|
|
4
|
+
providesAppNotificationSettings?: boolean;
|
|
5
|
+
provisional?: boolean;
|
|
6
|
+
announcement?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface NotificationPermissions extends NotificationPermissionOptions {
|
|
9
|
+
badge: boolean;
|
|
10
|
+
alert: boolean;
|
|
11
|
+
sound: boolean;
|
|
12
|
+
notificationCenter: boolean;
|
|
13
|
+
lockScreen: boolean;
|
|
14
|
+
}
|
package/package.json
CHANGED