@imatis/react-native-notifications 4.3.1-imatis.24 → 4.3.1-imatis.25
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/core/JsIOHelper.java +4 -0
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +17 -3
- package/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java +8 -0
- package/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/AppLaunchHelperTest.java +117 -0
- package/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/InitialNotificationHolderTest.java +59 -0
- package/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/JsIOHelperTest.java +60 -0
- package/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notification/PushNotificationTest.java +381 -0
- package/lib/android/app/src/test/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawerTest.java +96 -0
- package/lib/android/app/src/test/resources/robolectric.properties +1 -0
- package/package.json +2 -2
- package/android/app/src/reactNative59/reactNative59.iml +0 -11
- package/android/app/src/reactNative60/reactNative60.iml +0 -11
- package/lib/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/lib/android/.gradle/6.1.1/fileChanges/last-build.bin +0 -0
- package/lib/android/.gradle/6.1.1/fileHashes/fileHashes.bin +0 -0
- package/lib/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/lib/android/.gradle/6.1.1/gc.properties +0 -0
- package/lib/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/lib/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/lib/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/lib/android/.gradle/checksums/checksums.lock +0 -0
- package/lib/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/lib/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/lib/android/.gradle/vcs-1/gc.properties +0 -0
- package/lib/android/local.properties +0 -8
- package/lib/dist/DTO/Notification.d.ts +0 -11
- package/lib/dist/DTO/Notification.js +0 -28
- package/lib/dist/DTO/Notification.test.d.ts +0 -1
- package/lib/dist/DTO/Notification.test.js +0 -52
- package/lib/dist/DTO/NotificationAndroid.d.ts +0 -7
- package/lib/dist/DTO/NotificationAndroid.js +0 -20
- package/lib/dist/DTO/NotificationAndroid.test.d.ts +0 -1
- package/lib/dist/DTO/NotificationAndroid.test.js +0 -25
- package/lib/dist/DTO/NotificationFactory.d.ts +0 -4
- package/lib/dist/DTO/NotificationFactory.js +0 -18
- package/lib/dist/DTO/NotificationIOS.d.ts +0 -12
- package/lib/dist/DTO/NotificationIOS.js +0 -40
- package/lib/dist/DTO/NotificationIOS.test.d.ts +0 -1
- package/lib/dist/DTO/NotificationIOS.test.js +0 -58
- package/lib/dist/Notifications.d.ts +0 -65
- package/lib/dist/Notifications.js +0 -98
- package/lib/dist/NotificationsAndroid.d.ts +0 -14
- package/lib/dist/NotificationsAndroid.js +0 -32
- package/lib/dist/NotificationsIOS.d.ts +0 -51
- package/lib/dist/NotificationsIOS.js +0 -83
- package/lib/dist/adapters/CompletionCallbackWrapper.d.ts +0 -11
- package/lib/dist/adapters/CompletionCallbackWrapper.js +0 -44
- package/lib/dist/adapters/NativeCommandsSender.d.ts +0 -31
- package/lib/dist/adapters/NativeCommandsSender.js +0 -73
- package/lib/dist/adapters/NativeCommandsSender.mock.d.ts +0 -1
- package/lib/dist/adapters/NativeCommandsSender.mock.js +0 -4
- package/lib/dist/adapters/NativeEventsReceiver.d.ts +0 -19
- package/lib/dist/adapters/NativeEventsReceiver.js +0 -46
- package/lib/dist/adapters/NativeEventsReceiver.mock.d.ts +0 -1
- package/lib/dist/adapters/NativeEventsReceiver.mock.js +0 -4
- package/lib/dist/adapters/UniqueIdProvider.d.ts +0 -3
- package/lib/dist/adapters/UniqueIdProvider.js +0 -10
- package/lib/dist/commands/Commands.d.ts +0 -32
- package/lib/dist/commands/Commands.js +0 -79
- package/lib/dist/commands/Commands.test.d.ts +0 -1
- package/lib/dist/commands/Commands.test.js +0 -201
- package/lib/dist/events/EventsRegistry.d.ts +0 -18
- package/lib/dist/events/EventsRegistry.js +0 -28
- package/lib/dist/events/EventsRegistry.test.d.ts +0 -1
- package/lib/dist/events/EventsRegistry.test.js +0 -182
- package/lib/dist/events/EventsRegistryIOS.d.ts +0 -12
- package/lib/dist/events/EventsRegistryIOS.js +0 -19
- package/lib/dist/events/EventsRegistryIOS.test.d.ts +0 -1
- package/lib/dist/events/EventsRegistryIOS.test.js +0 -51
- package/lib/dist/index.d.ts +0 -7
- package/lib/dist/index.js +0 -12
- package/lib/dist/interfaces/EventSubscription.d.ts +0 -3
- package/lib/dist/interfaces/EventSubscription.js +0 -2
- package/lib/dist/interfaces/NotificationActionResponse.d.ts +0 -5
- package/lib/dist/interfaces/NotificationActionResponse.js +0 -10
- package/lib/dist/interfaces/NotificationCategory.d.ts +0 -18
- package/lib/dist/interfaces/NotificationCategory.js +0 -20
- package/lib/dist/interfaces/NotificationChannel.d.ts +0 -14
- package/lib/dist/interfaces/NotificationChannel.js +0 -2
- package/lib/dist/interfaces/NotificationCompletion.d.ts +0 -10
- package/lib/dist/interfaces/NotificationCompletion.js +0 -9
- package/lib/dist/interfaces/NotificationEvents.d.ts +0 -18
- package/lib/dist/interfaces/NotificationEvents.js +0 -2
- package/lib/dist/interfaces/NotificationPermissions.d.ts +0 -14
- package/lib/dist/interfaces/NotificationPermissions.js +0 -2
- package/lib/ios/RNNotifications.xcodeproj/project.xcworkspace/xcuserdata/troy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package-lock.json +0 -13507
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeCommandsSender = void 0;
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
5
|
-
class NativeCommandsSender {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.nativeCommandsModule = react_native_1.NativeModules.RNBridgeModule;
|
|
8
|
-
}
|
|
9
|
-
postLocalNotification(notification, id) {
|
|
10
|
-
return this.nativeCommandsModule.postLocalNotification(notification, id);
|
|
11
|
-
}
|
|
12
|
-
getInitialNotification() {
|
|
13
|
-
return this.nativeCommandsModule.getInitialNotification();
|
|
14
|
-
}
|
|
15
|
-
getLastAction() {
|
|
16
|
-
return this.nativeCommandsModule.getLastAction();
|
|
17
|
-
}
|
|
18
|
-
requestPermissions(options) {
|
|
19
|
-
return this.nativeCommandsModule.requestPermissions(options || {});
|
|
20
|
-
}
|
|
21
|
-
abandonPermissions() {
|
|
22
|
-
return this.nativeCommandsModule.abandonPermissions();
|
|
23
|
-
}
|
|
24
|
-
refreshToken() {
|
|
25
|
-
this.nativeCommandsModule.refreshToken();
|
|
26
|
-
}
|
|
27
|
-
registerPushKit() {
|
|
28
|
-
return this.nativeCommandsModule.registerPushKit();
|
|
29
|
-
}
|
|
30
|
-
setCategories(categories) {
|
|
31
|
-
this.nativeCommandsModule.setCategories(categories);
|
|
32
|
-
}
|
|
33
|
-
getBadgeCount() {
|
|
34
|
-
return this.nativeCommandsModule.getBadgeCount();
|
|
35
|
-
}
|
|
36
|
-
setBadgeCount(count) {
|
|
37
|
-
this.nativeCommandsModule.setBadgeCount(count);
|
|
38
|
-
}
|
|
39
|
-
cancelLocalNotification(notificationId) {
|
|
40
|
-
this.nativeCommandsModule.cancelLocalNotification(notificationId);
|
|
41
|
-
}
|
|
42
|
-
cancelAllLocalNotifications() {
|
|
43
|
-
this.nativeCommandsModule.cancelAllLocalNotifications();
|
|
44
|
-
}
|
|
45
|
-
isRegisteredForRemoteNotifications() {
|
|
46
|
-
return this.nativeCommandsModule.isRegisteredForRemoteNotifications();
|
|
47
|
-
}
|
|
48
|
-
checkPermissions() {
|
|
49
|
-
return this.nativeCommandsModule.checkPermissions();
|
|
50
|
-
}
|
|
51
|
-
removeAllDeliveredNotifications() {
|
|
52
|
-
return this.nativeCommandsModule.removeAllDeliveredNotifications();
|
|
53
|
-
}
|
|
54
|
-
removeDeliveredNotifications(identifiers) {
|
|
55
|
-
return this.nativeCommandsModule.removeDeliveredNotifications(identifiers);
|
|
56
|
-
}
|
|
57
|
-
getDeliveredNotifications() {
|
|
58
|
-
return this.nativeCommandsModule.getDeliveredNotifications();
|
|
59
|
-
}
|
|
60
|
-
finishPresentingNotification(notificationId, notificationCompletion) {
|
|
61
|
-
this.nativeCommandsModule.finishPresentingNotification(notificationId, notificationCompletion);
|
|
62
|
-
}
|
|
63
|
-
finishHandlingAction(notificationId) {
|
|
64
|
-
this.nativeCommandsModule.finishHandlingAction(notificationId);
|
|
65
|
-
}
|
|
66
|
-
setNotificationChannel(notificationChannel) {
|
|
67
|
-
this.nativeCommandsModule.setNotificationChannel(notificationChannel);
|
|
68
|
-
}
|
|
69
|
-
finishHandlingBackgroundAction(notificationId, backgroundFetchResult) {
|
|
70
|
-
this.nativeCommandsModule.finishHandlingBackgroundAction(notificationId, backgroundFetchResult);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.NativeCommandsSender = NativeCommandsSender;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const NativeCommandsSender: any;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EmitterSubscription } from 'react-native';
|
|
2
|
-
import { Registered, RegistrationError, RegisteredPushKit } from '../interfaces/NotificationEvents';
|
|
3
|
-
import { Notification } from '../DTO/Notification';
|
|
4
|
-
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse';
|
|
5
|
-
import { NotificationFactory } from '../DTO/NotificationFactory';
|
|
6
|
-
export declare class NativeEventsReceiver {
|
|
7
|
-
private readonly notificationFactory;
|
|
8
|
-
private emitter;
|
|
9
|
-
constructor(notificationFactory: NotificationFactory);
|
|
10
|
-
registerRemoteNotificationsRegistered(callback: (event: Registered) => void): EmitterSubscription;
|
|
11
|
-
appNotificationSettingsLinked(callback: () => void): EmitterSubscription;
|
|
12
|
-
registerPushKitRegistered(callback: (event: RegisteredPushKit) => void): EmitterSubscription;
|
|
13
|
-
registerNotificationReceived(callback: (notification: Notification) => void): EmitterSubscription;
|
|
14
|
-
registerNotificationReceivedBackground(callback: (notification: Notification) => void): EmitterSubscription;
|
|
15
|
-
registerPushKitNotificationReceived(callback: (event: object) => void): EmitterSubscription;
|
|
16
|
-
registerNotificationOpened(callback: (notification: Notification, actionResponse?: NotificationActionResponse) => void): EmitterSubscription;
|
|
17
|
-
registerRemoteNotificationsRegistrationFailed(callback: (event: RegistrationError) => void): EmitterSubscription;
|
|
18
|
-
registerRemoteNotificationsRegistrationDenied(callback: () => void): EmitterSubscription;
|
|
19
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeEventsReceiver = void 0;
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
5
|
-
const NotificationActionResponse_1 = require("../interfaces/NotificationActionResponse");
|
|
6
|
-
class NativeEventsReceiver {
|
|
7
|
-
constructor(notificationFactory) {
|
|
8
|
-
this.notificationFactory = notificationFactory;
|
|
9
|
-
this.emitter = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.RNEventEmitter);
|
|
10
|
-
}
|
|
11
|
-
registerRemoteNotificationsRegistered(callback) {
|
|
12
|
-
return this.emitter.addListener('remoteNotificationsRegistered', callback);
|
|
13
|
-
}
|
|
14
|
-
appNotificationSettingsLinked(callback) {
|
|
15
|
-
return this.emitter.addListener('appNotificationSettingsLinked', callback);
|
|
16
|
-
}
|
|
17
|
-
registerPushKitRegistered(callback) {
|
|
18
|
-
return this.emitter.addListener('pushKitRegistered', callback);
|
|
19
|
-
}
|
|
20
|
-
registerNotificationReceived(callback) {
|
|
21
|
-
return this.emitter.addListener('notificationReceived', (payload) => {
|
|
22
|
-
callback(this.notificationFactory.fromPayload(payload));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
registerNotificationReceivedBackground(callback) {
|
|
26
|
-
return this.emitter.addListener('notificationReceivedBackground', (payload) => {
|
|
27
|
-
callback(this.notificationFactory.fromPayload(payload));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
registerPushKitNotificationReceived(callback) {
|
|
31
|
-
return this.emitter.addListener('pushKitNotificationReceived', callback);
|
|
32
|
-
}
|
|
33
|
-
registerNotificationOpened(callback) {
|
|
34
|
-
return this.emitter.addListener('notificationOpened', (response) => {
|
|
35
|
-
const action = response.action ? new NotificationActionResponse_1.NotificationActionResponse(response.action) : undefined;
|
|
36
|
-
callback(this.notificationFactory.fromPayload(response.notification), action);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
registerRemoteNotificationsRegistrationFailed(callback) {
|
|
40
|
-
return this.emitter.addListener('remoteNotificationsRegistrationFailed', callback);
|
|
41
|
-
}
|
|
42
|
-
registerRemoteNotificationsRegistrationDenied(callback) {
|
|
43
|
-
return this.emitter.addListener('remoteNotificationsRegistrationDenied', callback);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.NativeEventsReceiver = NativeEventsReceiver;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const NativeEventsReceiver: any;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniqueIdProvider = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
|
-
class UniqueIdProvider {
|
|
6
|
-
generate() {
|
|
7
|
-
return parseInt(_.uniqueId());
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.UniqueIdProvider = UniqueIdProvider;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { NativeCommandsSender } from '../adapters/NativeCommandsSender';
|
|
2
|
-
import { Notification } from '../DTO/Notification';
|
|
3
|
-
import { NotificationCategory } from '../interfaces/NotificationCategory';
|
|
4
|
-
import { NotificationChannel } from '../interfaces/NotificationChannel';
|
|
5
|
-
import { NotificationPermissions } from '../interfaces/NotificationPermissions';
|
|
6
|
-
import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
|
|
7
|
-
import { NotificationFactory } from '../DTO/NotificationFactory';
|
|
8
|
-
import { NotificationPermissionOptions } from '../interfaces/NotificationPermissions';
|
|
9
|
-
export declare class Commands {
|
|
10
|
-
private readonly nativeCommandsSender;
|
|
11
|
-
private readonly uniqueIdProvider;
|
|
12
|
-
private readonly notificationFactory;
|
|
13
|
-
constructor(nativeCommandsSender: NativeCommandsSender, uniqueIdProvider: UniqueIdProvider, notificationFactory: NotificationFactory);
|
|
14
|
-
postLocalNotification(notification: Notification, id?: number): number;
|
|
15
|
-
getInitialNotification(): Promise<Notification | undefined>;
|
|
16
|
-
getLastAction(): Promise<Notification | undefined>;
|
|
17
|
-
requestPermissions(options?: NotificationPermissionOptions): void;
|
|
18
|
-
abandonPermissions(): void;
|
|
19
|
-
registerPushKit(): void;
|
|
20
|
-
setCategories(categories: [NotificationCategory?]): void;
|
|
21
|
-
getBadgeCount(): Promise<number>;
|
|
22
|
-
setBadgeCount(count: number): void;
|
|
23
|
-
cancelLocalNotification(notificationId: number): void;
|
|
24
|
-
cancelAllLocalNotifications(): void;
|
|
25
|
-
isRegisteredForRemoteNotifications(): Promise<boolean>;
|
|
26
|
-
checkPermissions(): Promise<NotificationPermissions>;
|
|
27
|
-
removeAllDeliveredNotifications(): void;
|
|
28
|
-
removeDeliveredNotifications(identifiers: Array<string>): void;
|
|
29
|
-
getDeliveredNotifications(): Promise<Notification[]>;
|
|
30
|
-
refreshToken(): void;
|
|
31
|
-
setNotificationChannel(notificationChannel: NotificationChannel): void;
|
|
32
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Commands = void 0;
|
|
4
|
-
class Commands {
|
|
5
|
-
constructor(nativeCommandsSender, uniqueIdProvider, notificationFactory) {
|
|
6
|
-
this.nativeCommandsSender = nativeCommandsSender;
|
|
7
|
-
this.uniqueIdProvider = uniqueIdProvider;
|
|
8
|
-
this.notificationFactory = notificationFactory;
|
|
9
|
-
}
|
|
10
|
-
postLocalNotification(notification, id) {
|
|
11
|
-
const notificationId = id ? id : this.uniqueIdProvider.generate();
|
|
12
|
-
this.nativeCommandsSender.postLocalNotification(notification, notificationId);
|
|
13
|
-
return notificationId;
|
|
14
|
-
}
|
|
15
|
-
async getInitialNotification() {
|
|
16
|
-
return this.nativeCommandsSender.getInitialNotification().then((payload) => {
|
|
17
|
-
if (payload) {
|
|
18
|
-
return this.notificationFactory.fromPayload(payload);
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async getLastAction() {
|
|
24
|
-
return this.nativeCommandsSender.getLastAction().then((payload) => {
|
|
25
|
-
if (payload) {
|
|
26
|
-
return this.notificationFactory.fromPayload(payload);
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
requestPermissions(options) {
|
|
32
|
-
const result = this.nativeCommandsSender.requestPermissions(options);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
abandonPermissions() {
|
|
36
|
-
const result = this.nativeCommandsSender.abandonPermissions();
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
registerPushKit() {
|
|
40
|
-
this.nativeCommandsSender.registerPushKit();
|
|
41
|
-
}
|
|
42
|
-
setCategories(categories) {
|
|
43
|
-
this.nativeCommandsSender.setCategories(categories);
|
|
44
|
-
}
|
|
45
|
-
getBadgeCount() {
|
|
46
|
-
return this.nativeCommandsSender.getBadgeCount();
|
|
47
|
-
}
|
|
48
|
-
setBadgeCount(count) {
|
|
49
|
-
this.nativeCommandsSender.setBadgeCount(count);
|
|
50
|
-
}
|
|
51
|
-
cancelLocalNotification(notificationId) {
|
|
52
|
-
this.nativeCommandsSender.cancelLocalNotification(notificationId);
|
|
53
|
-
}
|
|
54
|
-
cancelAllLocalNotifications() {
|
|
55
|
-
this.nativeCommandsSender.cancelAllLocalNotifications();
|
|
56
|
-
}
|
|
57
|
-
isRegisteredForRemoteNotifications() {
|
|
58
|
-
return this.nativeCommandsSender.isRegisteredForRemoteNotifications();
|
|
59
|
-
}
|
|
60
|
-
checkPermissions() {
|
|
61
|
-
return this.nativeCommandsSender.checkPermissions();
|
|
62
|
-
}
|
|
63
|
-
removeAllDeliveredNotifications() {
|
|
64
|
-
this.nativeCommandsSender.removeAllDeliveredNotifications();
|
|
65
|
-
}
|
|
66
|
-
removeDeliveredNotifications(identifiers) {
|
|
67
|
-
return this.nativeCommandsSender.removeDeliveredNotifications(identifiers);
|
|
68
|
-
}
|
|
69
|
-
getDeliveredNotifications() {
|
|
70
|
-
return this.nativeCommandsSender.getDeliveredNotifications();
|
|
71
|
-
}
|
|
72
|
-
refreshToken() {
|
|
73
|
-
this.nativeCommandsSender.refreshToken();
|
|
74
|
-
}
|
|
75
|
-
setNotificationChannel(notificationChannel) {
|
|
76
|
-
this.nativeCommandsSender.setNotificationChannel(notificationChannel);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.Commands = Commands;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ts_mockito_1 = require("ts-mockito");
|
|
4
|
-
const Commands_1 = require("./Commands");
|
|
5
|
-
const NativeCommandsSender_1 = require("../adapters/NativeCommandsSender");
|
|
6
|
-
const Notification_1 = require("../DTO/Notification");
|
|
7
|
-
const UniqueIdProvider_1 = require("../adapters/UniqueIdProvider");
|
|
8
|
-
const NotificationFactory_1 = require("../DTO/NotificationFactory");
|
|
9
|
-
const NotificationAndroid_1 = require("../DTO/NotificationAndroid");
|
|
10
|
-
const react_native_1 = require("react-native");
|
|
11
|
-
const NotificationIOS_1 = require("../DTO/NotificationIOS");
|
|
12
|
-
describe('Commands', () => {
|
|
13
|
-
let uut;
|
|
14
|
-
let mockedNativeCommandsSender;
|
|
15
|
-
let mockedUniqueIdProvider;
|
|
16
|
-
let notificationFactory;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
notificationFactory = new NotificationFactory_1.NotificationFactory();
|
|
19
|
-
mockedNativeCommandsSender = ts_mockito_1.mock(NativeCommandsSender_1.NativeCommandsSender);
|
|
20
|
-
mockedUniqueIdProvider = ts_mockito_1.mock(UniqueIdProvider_1.UniqueIdProvider);
|
|
21
|
-
ts_mockito_1.when(mockedUniqueIdProvider.generate()).thenCall(() => 12);
|
|
22
|
-
uut = new Commands_1.Commands(ts_mockito_1.instance(mockedNativeCommandsSender), ts_mockito_1.instance(mockedUniqueIdProvider), notificationFactory);
|
|
23
|
-
});
|
|
24
|
-
describe('getInitialNotification', () => {
|
|
25
|
-
it('sends to native', () => {
|
|
26
|
-
uut.getInitialNotification();
|
|
27
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.getInitialNotification()).called();
|
|
28
|
-
});
|
|
29
|
-
it('Android - returns a promise with the initial notification', async () => {
|
|
30
|
-
react_native_1.Platform.OS = 'android';
|
|
31
|
-
const expectedNotification = new NotificationAndroid_1.NotificationAndroid({ 'google.message_id': 'id' });
|
|
32
|
-
ts_mockito_1.when(mockedNativeCommandsSender.getInitialNotification()).thenResolve({ 'google.message_id': 'id' });
|
|
33
|
-
const result = await uut.getInitialNotification();
|
|
34
|
-
expect(result).toEqual(expectedNotification);
|
|
35
|
-
});
|
|
36
|
-
it('Should return undefined initial notification', async () => {
|
|
37
|
-
react_native_1.Platform.OS = 'android';
|
|
38
|
-
ts_mockito_1.when(mockedNativeCommandsSender.getInitialNotification()).thenResolve();
|
|
39
|
-
const result = await uut.getInitialNotification();
|
|
40
|
-
expect(result).toEqual(undefined);
|
|
41
|
-
});
|
|
42
|
-
it('iOS - returns a promise with the initial notification', async () => {
|
|
43
|
-
react_native_1.Platform.OS = 'ios';
|
|
44
|
-
const expectedNotification = new NotificationIOS_1.NotificationIOS({ identifier: 'id' });
|
|
45
|
-
ts_mockito_1.when(mockedNativeCommandsSender.getInitialNotification()).thenResolve({ identifier: 'id' });
|
|
46
|
-
const result = await uut.getInitialNotification();
|
|
47
|
-
expect(result).toEqual(expectedNotification);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('requestPermissions', () => {
|
|
51
|
-
it('sends to native', () => {
|
|
52
|
-
const opts = {};
|
|
53
|
-
uut.requestPermissions(opts);
|
|
54
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.requestPermissions(opts)).called();
|
|
55
|
-
});
|
|
56
|
-
it('sends to native with options', () => {
|
|
57
|
-
const opts = { criticalAlert: true };
|
|
58
|
-
uut.requestPermissions(opts);
|
|
59
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.requestPermissions(opts)).called();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('registerPushKit', () => {
|
|
63
|
-
it('sends to native', () => {
|
|
64
|
-
uut.registerPushKit();
|
|
65
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.registerPushKit()).called();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
describe('setCategories', () => {
|
|
69
|
-
it('sends to native', () => {
|
|
70
|
-
const emptyCategoriesArray = [];
|
|
71
|
-
uut.setCategories(emptyCategoriesArray);
|
|
72
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.setCategories(emptyCategoriesArray)).called();
|
|
73
|
-
});
|
|
74
|
-
it('sends to native with categories', () => {
|
|
75
|
-
const category = { identifier: 'id', actions: [] };
|
|
76
|
-
const categoriesArray = [category];
|
|
77
|
-
uut.setCategories(categoriesArray);
|
|
78
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.setCategories(categoriesArray)).called();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('abandonPermissions', () => {
|
|
82
|
-
it('sends to native', () => {
|
|
83
|
-
uut.abandonPermissions();
|
|
84
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.abandonPermissions()).called();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe('postLocalNotification', () => {
|
|
88
|
-
it('sends to native', () => {
|
|
89
|
-
const notification = new Notification_1.Notification({ identifier: 'id' });
|
|
90
|
-
uut.postLocalNotification(notification);
|
|
91
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.postLocalNotification(notification, ts_mockito_1.anyNumber())).called();
|
|
92
|
-
});
|
|
93
|
-
it('generates unique identifier', () => {
|
|
94
|
-
const notification = new Notification_1.Notification({ identifier: 'id' });
|
|
95
|
-
uut.postLocalNotification(notification);
|
|
96
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.postLocalNotification(notification, ts_mockito_1.anyNumber())).called();
|
|
97
|
-
});
|
|
98
|
-
it('use passed notification id', () => {
|
|
99
|
-
const notification = new Notification_1.Notification({ identifier: 'id' });
|
|
100
|
-
const passedId = 2;
|
|
101
|
-
uut.postLocalNotification(notification, passedId);
|
|
102
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.postLocalNotification(notification, passedId)).called();
|
|
103
|
-
});
|
|
104
|
-
it('return notification id', () => {
|
|
105
|
-
const notification = new Notification_1.Notification({ identifier: 'id' });
|
|
106
|
-
const notificationId = 2;
|
|
107
|
-
const response = uut.postLocalNotification(notification, notificationId);
|
|
108
|
-
expect(response).toEqual(notificationId);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
describe('getBadgeCount', () => {
|
|
112
|
-
it('sends to native', () => {
|
|
113
|
-
uut.getBadgeCount();
|
|
114
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.getBadgeCount()).called();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
describe('setBadgeCount', () => {
|
|
118
|
-
it('sends to native', () => {
|
|
119
|
-
uut.setBadgeCount(10);
|
|
120
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.setBadgeCount(10)).called();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe('cancelLocalNotification', () => {
|
|
124
|
-
it('sends to native', () => {
|
|
125
|
-
const notificationId = 1;
|
|
126
|
-
uut.cancelLocalNotification(notificationId);
|
|
127
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.cancelLocalNotification(notificationId)).called();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
describe('cancelAllLocalNotifications', () => {
|
|
131
|
-
it('sends to native', () => {
|
|
132
|
-
uut.cancelAllLocalNotifications();
|
|
133
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.cancelAllLocalNotifications()).called();
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
describe('isRegisteredForRemoteNotifications', () => {
|
|
137
|
-
it('sends to native', () => {
|
|
138
|
-
uut.isRegisteredForRemoteNotifications();
|
|
139
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.isRegisteredForRemoteNotifications()).called();
|
|
140
|
-
});
|
|
141
|
-
it('return positive response from native', async () => {
|
|
142
|
-
ts_mockito_1.when(mockedNativeCommandsSender.isRegisteredForRemoteNotifications()).thenResolve(true);
|
|
143
|
-
const isRegistered = await uut.isRegisteredForRemoteNotifications();
|
|
144
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.isRegisteredForRemoteNotifications()).called();
|
|
145
|
-
expect(isRegistered).toEqual(true);
|
|
146
|
-
});
|
|
147
|
-
it('return negative response from native', async () => {
|
|
148
|
-
ts_mockito_1.when(mockedNativeCommandsSender.isRegisteredForRemoteNotifications()).thenResolve(false);
|
|
149
|
-
const isRegistered = await uut.isRegisteredForRemoteNotifications();
|
|
150
|
-
expect(isRegistered).toEqual(false);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
describe('checkPermissions', () => {
|
|
154
|
-
it('sends to native', () => {
|
|
155
|
-
uut.checkPermissions();
|
|
156
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.checkPermissions()).called();
|
|
157
|
-
});
|
|
158
|
-
it('return negative response from native', async () => {
|
|
159
|
-
const expectedPermissions = {
|
|
160
|
-
badge: false,
|
|
161
|
-
alert: true,
|
|
162
|
-
sound: false,
|
|
163
|
-
carPlay: false,
|
|
164
|
-
criticalAlert: false,
|
|
165
|
-
providesAppNotificationSettings: false,
|
|
166
|
-
provisional: false,
|
|
167
|
-
announcement: false,
|
|
168
|
-
notificationCenter: true,
|
|
169
|
-
lockScreen: false,
|
|
170
|
-
};
|
|
171
|
-
ts_mockito_1.when(mockedNativeCommandsSender.checkPermissions()).thenResolve(expectedPermissions);
|
|
172
|
-
const permissions = await uut.checkPermissions();
|
|
173
|
-
expect(permissions).toEqual(expectedPermissions);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe('removeAllDeliveredNotifications', () => {
|
|
177
|
-
it('sends to native', () => {
|
|
178
|
-
uut.removeAllDeliveredNotifications();
|
|
179
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.removeAllDeliveredNotifications()).called();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
describe('removeDeliveredNotifications', () => {
|
|
183
|
-
it('sends to native', () => {
|
|
184
|
-
const identifiers = ["id1", "id2"];
|
|
185
|
-
uut.removeDeliveredNotifications(identifiers);
|
|
186
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.removeDeliveredNotifications(identifiers)).called();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
describe('getDeliveredNotifications', () => {
|
|
190
|
-
it('sends to native', () => {
|
|
191
|
-
uut.getDeliveredNotifications();
|
|
192
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.getDeliveredNotifications()).called();
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe('refreshToken', () => {
|
|
196
|
-
it('sends to native', () => {
|
|
197
|
-
uut.refreshToken();
|
|
198
|
-
ts_mockito_1.verify(mockedNativeCommandsSender.refreshToken()).called();
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventsRegistry = void 0;
|
|
4
|
-
class EventsRegistry {
|
|
5
|
-
constructor(nativeEventsReceiver, completionCallbackWrapper) {
|
|
6
|
-
this.nativeEventsReceiver = nativeEventsReceiver;
|
|
7
|
-
this.completionCallbackWrapper = completionCallbackWrapper;
|
|
8
|
-
}
|
|
9
|
-
registerRemoteNotificationsRegistered(callback) {
|
|
10
|
-
return this.nativeEventsReceiver.registerRemoteNotificationsRegistered(callback);
|
|
11
|
-
}
|
|
12
|
-
registerNotificationReceivedForeground(callback) {
|
|
13
|
-
return this.nativeEventsReceiver.registerNotificationReceived(this.completionCallbackWrapper.wrapReceivedForegroundCallback(callback));
|
|
14
|
-
}
|
|
15
|
-
registerNotificationReceivedBackground(callback) {
|
|
16
|
-
return this.nativeEventsReceiver.registerNotificationReceivedBackground(this.completionCallbackWrapper.wrapReceivedBackgroundCallback(callback));
|
|
17
|
-
}
|
|
18
|
-
registerNotificationOpened(callback) {
|
|
19
|
-
return this.nativeEventsReceiver.registerNotificationOpened(this.completionCallbackWrapper.wrapOpenedCallback(callback));
|
|
20
|
-
}
|
|
21
|
-
registerRemoteNotificationsRegistrationFailed(callback) {
|
|
22
|
-
return this.nativeEventsReceiver.registerRemoteNotificationsRegistrationFailed(callback);
|
|
23
|
-
}
|
|
24
|
-
registerRemoteNotificationsRegistrationDenied(callback) {
|
|
25
|
-
return this.nativeEventsReceiver.registerRemoteNotificationsRegistrationDenied(callback);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.EventsRegistry = EventsRegistry;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|