@imatis/react-native-notifications 4.3.3-imatis.11 → 4.3.3-imatis.13
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/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationProps.java +8 -0
- 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,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
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationsIOS = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
class NotificationsIOS {
|
|
6
|
+
commands;
|
|
7
|
+
eventsRegistry;
|
|
8
|
+
constructor(commands, eventsRegistry) {
|
|
9
|
+
this.commands = commands;
|
|
10
|
+
this.eventsRegistry = eventsRegistry;
|
|
11
|
+
return new Proxy(this, {
|
|
12
|
+
get(target, name) {
|
|
13
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
14
|
+
return target[name];
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return () => { };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Request permissions to send remote notifications
|
|
24
|
+
*/
|
|
25
|
+
registerRemoteNotifications(options) {
|
|
26
|
+
return this.commands.requestPermissions(options);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Unregister for all remote notifications received via Apple Push Notification service
|
|
30
|
+
*/
|
|
31
|
+
abandonPermissions() {
|
|
32
|
+
return this.commands.abandonPermissions();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* registerPushKit
|
|
36
|
+
*/
|
|
37
|
+
registerPushKit() {
|
|
38
|
+
return this.commands.registerPushKit();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* getBadgeCount
|
|
42
|
+
*/
|
|
43
|
+
getBadgeCount() {
|
|
44
|
+
return this.commands.getBadgeCount();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* setBadgeCount
|
|
48
|
+
* @param count number of the new badge count
|
|
49
|
+
*/
|
|
50
|
+
setBadgeCount(count) {
|
|
51
|
+
return this.commands.setBadgeCount(count);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* cancelAllLocalNotifications
|
|
55
|
+
*/
|
|
56
|
+
cancelAllLocalNotifications() {
|
|
57
|
+
this.commands.cancelAllLocalNotifications();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* checkPermissions
|
|
61
|
+
*/
|
|
62
|
+
checkPermissions() {
|
|
63
|
+
return this.commands.checkPermissions();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* removeDeliveredNotifications
|
|
67
|
+
* @param identifiers Array of notification identifiers
|
|
68
|
+
*/
|
|
69
|
+
removeDeliveredNotifications(identifiers) {
|
|
70
|
+
return this.commands.removeDeliveredNotifications(identifiers);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* getDeliveredNotifications
|
|
74
|
+
*/
|
|
75
|
+
getDeliveredNotifications() {
|
|
76
|
+
return this.commands.getDeliveredNotifications();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Obtain the events registry instance
|
|
80
|
+
*/
|
|
81
|
+
events() {
|
|
82
|
+
return this.eventsRegistry;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.NotificationsIOS = NotificationsIOS;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NativeCommandsSender } from './NativeCommandsSender';
|
|
2
|
+
import { Notification } from "..";
|
|
3
|
+
import { NotificationActionResponse } from '../interfaces/NotificationActionResponse';
|
|
4
|
+
export declare class CompletionCallbackWrapper {
|
|
5
|
+
private readonly nativeCommandsSender;
|
|
6
|
+
constructor(nativeCommandsSender: NativeCommandsSender);
|
|
7
|
+
wrapReceivedBackgroundCallback(callback: Function): (notification: Notification) => void;
|
|
8
|
+
wrapReceivedForegroundCallback(callback: Function): (notification: Notification) => void;
|
|
9
|
+
private wrapReceivedAndInvoke;
|
|
10
|
+
wrapOpenedCallback(callback: Function): (notification: object, actionResponse?: NotificationActionResponse) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompletionCallbackWrapper = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
class CompletionCallbackWrapper {
|
|
6
|
+
nativeCommandsSender;
|
|
7
|
+
constructor(nativeCommandsSender) {
|
|
8
|
+
this.nativeCommandsSender = nativeCommandsSender;
|
|
9
|
+
}
|
|
10
|
+
wrapReceivedBackgroundCallback(callback) {
|
|
11
|
+
return (notification) => {
|
|
12
|
+
this.wrapReceivedAndInvoke(callback, notification, true);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
wrapReceivedForegroundCallback(callback) {
|
|
16
|
+
return (notification) => {
|
|
17
|
+
this.wrapReceivedAndInvoke(callback, notification, false);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
wrapReceivedAndInvoke(callback, notification, background) {
|
|
21
|
+
const completion = (response) => {
|
|
22
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
23
|
+
const identifier = notification.identifier;
|
|
24
|
+
if (background) {
|
|
25
|
+
this.nativeCommandsSender.finishHandlingBackgroundAction(identifier, response);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.nativeCommandsSender.finishPresentingNotification(identifier, response);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
callback(notification, completion);
|
|
33
|
+
}
|
|
34
|
+
wrapOpenedCallback(callback) {
|
|
35
|
+
return (notification, actionResponse) => {
|
|
36
|
+
const completion = () => {
|
|
37
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
38
|
+
this.nativeCommandsSender.finishHandlingAction(notification.identifier);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
callback(notification, completion, actionResponse);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CompletionCallbackWrapper = CompletionCallbackWrapper;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Notification } from '../DTO/Notification';
|
|
2
|
+
import { NotificationCompletion } from '../interfaces/NotificationCompletion';
|
|
3
|
+
import { NotificationPermissions } from '../interfaces/NotificationPermissions';
|
|
4
|
+
import { NotificationCategory } from '../interfaces/NotificationCategory';
|
|
5
|
+
import { NotificationChannel } from '../interfaces/NotificationChannel';
|
|
6
|
+
import { NotificationPermissionOptions } from '../interfaces/NotificationPermissions';
|
|
7
|
+
export declare class NativeCommandsSender {
|
|
8
|
+
private readonly nativeCommandsModule;
|
|
9
|
+
constructor();
|
|
10
|
+
postLocalNotification(notification: Notification, id: number): void;
|
|
11
|
+
getInitialNotification(): Promise<Object>;
|
|
12
|
+
getLastAction(): Promise<Object>;
|
|
13
|
+
requestPermissions(options?: NotificationPermissionOptions): void;
|
|
14
|
+
abandonPermissions(): void;
|
|
15
|
+
refreshToken(): void;
|
|
16
|
+
registerPushKit(): void;
|
|
17
|
+
setCategories(categories: [NotificationCategory?]): void;
|
|
18
|
+
getBadgeCount(): Promise<number>;
|
|
19
|
+
setBadgeCount(count: number): void;
|
|
20
|
+
cancelLocalNotification(notificationId: number): void;
|
|
21
|
+
cancelAllLocalNotifications(): void;
|
|
22
|
+
isRegisteredForRemoteNotifications(): Promise<any>;
|
|
23
|
+
checkPermissions(): Promise<NotificationPermissions>;
|
|
24
|
+
removeAllDeliveredNotifications(): void;
|
|
25
|
+
removeDeliveredNotifications(identifiers: Array<string>): void;
|
|
26
|
+
getDeliveredNotifications(): Promise<Notification[]>;
|
|
27
|
+
finishPresentingNotification(notificationId: string, notificationCompletion: NotificationCompletion): void;
|
|
28
|
+
finishHandlingAction(notificationId: string): void;
|
|
29
|
+
setNotificationChannel(notificationChannel: NotificationChannel): void;
|
|
30
|
+
finishHandlingBackgroundAction(notificationId: string, backgroundFetchResult: string): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
nativeCommandsModule;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.nativeCommandsModule = react_native_1.NativeModules.RNBridgeModule;
|
|
9
|
+
}
|
|
10
|
+
postLocalNotification(notification, id) {
|
|
11
|
+
return this.nativeCommandsModule.postLocalNotification(notification, id);
|
|
12
|
+
}
|
|
13
|
+
getInitialNotification() {
|
|
14
|
+
return this.nativeCommandsModule.getInitialNotification();
|
|
15
|
+
}
|
|
16
|
+
getLastAction() {
|
|
17
|
+
return this.nativeCommandsModule.getLastAction();
|
|
18
|
+
}
|
|
19
|
+
requestPermissions(options) {
|
|
20
|
+
return this.nativeCommandsModule.requestPermissions(options || {});
|
|
21
|
+
}
|
|
22
|
+
abandonPermissions() {
|
|
23
|
+
return this.nativeCommandsModule.abandonPermissions();
|
|
24
|
+
}
|
|
25
|
+
refreshToken() {
|
|
26
|
+
this.nativeCommandsModule.refreshToken();
|
|
27
|
+
}
|
|
28
|
+
registerPushKit() {
|
|
29
|
+
return this.nativeCommandsModule.registerPushKit();
|
|
30
|
+
}
|
|
31
|
+
setCategories(categories) {
|
|
32
|
+
this.nativeCommandsModule.setCategories(categories);
|
|
33
|
+
}
|
|
34
|
+
getBadgeCount() {
|
|
35
|
+
return this.nativeCommandsModule.getBadgeCount();
|
|
36
|
+
}
|
|
37
|
+
setBadgeCount(count) {
|
|
38
|
+
this.nativeCommandsModule.setBadgeCount(count);
|
|
39
|
+
}
|
|
40
|
+
cancelLocalNotification(notificationId) {
|
|
41
|
+
this.nativeCommandsModule.cancelLocalNotification(notificationId);
|
|
42
|
+
}
|
|
43
|
+
cancelAllLocalNotifications() {
|
|
44
|
+
this.nativeCommandsModule.cancelAllLocalNotifications();
|
|
45
|
+
}
|
|
46
|
+
isRegisteredForRemoteNotifications() {
|
|
47
|
+
return this.nativeCommandsModule.isRegisteredForRemoteNotifications();
|
|
48
|
+
}
|
|
49
|
+
checkPermissions() {
|
|
50
|
+
return this.nativeCommandsModule.checkPermissions();
|
|
51
|
+
}
|
|
52
|
+
removeAllDeliveredNotifications() {
|
|
53
|
+
return this.nativeCommandsModule.removeAllDeliveredNotifications();
|
|
54
|
+
}
|
|
55
|
+
removeDeliveredNotifications(identifiers) {
|
|
56
|
+
return this.nativeCommandsModule.removeDeliveredNotifications(identifiers);
|
|
57
|
+
}
|
|
58
|
+
getDeliveredNotifications() {
|
|
59
|
+
return this.nativeCommandsModule.getDeliveredNotifications();
|
|
60
|
+
}
|
|
61
|
+
finishPresentingNotification(notificationId, notificationCompletion) {
|
|
62
|
+
this.nativeCommandsModule.finishPresentingNotification(notificationId, notificationCompletion);
|
|
63
|
+
}
|
|
64
|
+
finishHandlingAction(notificationId) {
|
|
65
|
+
this.nativeCommandsModule.finishHandlingAction(notificationId);
|
|
66
|
+
}
|
|
67
|
+
setNotificationChannel(notificationChannel) {
|
|
68
|
+
this.nativeCommandsModule.setNotificationChannel(notificationChannel);
|
|
69
|
+
}
|
|
70
|
+
finishHandlingBackgroundAction(notificationId, backgroundFetchResult) {
|
|
71
|
+
this.nativeCommandsModule.finishHandlingBackgroundAction(notificationId, backgroundFetchResult);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.NativeCommandsSender = NativeCommandsSender;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
const NotificationFactory_1 = require("../DTO/NotificationFactory");
|
|
7
|
+
class NativeEventsReceiver {
|
|
8
|
+
notificationFactory;
|
|
9
|
+
emitter;
|
|
10
|
+
constructor(notificationFactory = new NotificationFactory_1.NotificationFactory()) {
|
|
11
|
+
this.notificationFactory = notificationFactory;
|
|
12
|
+
this.emitter = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.RNEventEmitter);
|
|
13
|
+
}
|
|
14
|
+
registerRemoteNotificationsRegistered(callback) {
|
|
15
|
+
return this.emitter.addListener('remoteNotificationsRegistered', callback);
|
|
16
|
+
}
|
|
17
|
+
appNotificationSettingsLinked(callback) {
|
|
18
|
+
return this.emitter.addListener('appNotificationSettingsLinked', callback);
|
|
19
|
+
}
|
|
20
|
+
registerPushKitRegistered(callback) {
|
|
21
|
+
return this.emitter.addListener('pushKitRegistered', callback);
|
|
22
|
+
}
|
|
23
|
+
registerNotificationReceived(callback) {
|
|
24
|
+
return this.emitter.addListener('notificationReceived', (payload) => {
|
|
25
|
+
callback(this.notificationFactory.fromPayload(payload));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
registerNotificationReceivedBackground(callback) {
|
|
29
|
+
return this.emitter.addListener('notificationReceivedBackground', (payload) => {
|
|
30
|
+
callback(this.notificationFactory.fromPayload(payload));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
registerPushKitNotificationReceived(callback) {
|
|
34
|
+
return this.emitter.addListener('pushKitNotificationReceived', callback);
|
|
35
|
+
}
|
|
36
|
+
registerNotificationOpened(callback) {
|
|
37
|
+
return this.emitter.addListener('notificationOpened', (response) => {
|
|
38
|
+
const action = response.action ? new NotificationActionResponse_1.NotificationActionResponse(response.action) : undefined;
|
|
39
|
+
callback(this.notificationFactory.fromPayload(response.notification), action);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
registerRemoteNotificationsRegistrationFailed(callback) {
|
|
43
|
+
return this.emitter.addListener('remoteNotificationsRegistrationFailed', callback);
|
|
44
|
+
}
|
|
45
|
+
registerRemoteNotificationsRegistrationDenied(callback) {
|
|
46
|
+
return this.emitter.addListener('remoteNotificationsRegistrationDenied', callback);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.NativeEventsReceiver = NativeEventsReceiver;
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Commands = void 0;
|
|
4
|
+
class Commands {
|
|
5
|
+
nativeCommandsSender;
|
|
6
|
+
uniqueIdProvider;
|
|
7
|
+
notificationFactory;
|
|
8
|
+
constructor(nativeCommandsSender, uniqueIdProvider, notificationFactory) {
|
|
9
|
+
this.nativeCommandsSender = nativeCommandsSender;
|
|
10
|
+
this.uniqueIdProvider = uniqueIdProvider;
|
|
11
|
+
this.notificationFactory = notificationFactory;
|
|
12
|
+
}
|
|
13
|
+
postLocalNotification(notification, id) {
|
|
14
|
+
const notificationId = id ? id : this.uniqueIdProvider.generate();
|
|
15
|
+
this.nativeCommandsSender.postLocalNotification(notification, notificationId);
|
|
16
|
+
return notificationId;
|
|
17
|
+
}
|
|
18
|
+
async getInitialNotification() {
|
|
19
|
+
return this.nativeCommandsSender.getInitialNotification().then((payload) => {
|
|
20
|
+
if (payload) {
|
|
21
|
+
return this.notificationFactory.fromPayload(payload);
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async getLastAction() {
|
|
27
|
+
return this.nativeCommandsSender.getLastAction().then((payload) => {
|
|
28
|
+
if (payload) {
|
|
29
|
+
return this.notificationFactory.fromPayload(payload);
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
requestPermissions(options) {
|
|
35
|
+
const result = this.nativeCommandsSender.requestPermissions(options);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
abandonPermissions() {
|
|
39
|
+
const result = this.nativeCommandsSender.abandonPermissions();
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
registerPushKit() {
|
|
43
|
+
this.nativeCommandsSender.registerPushKit();
|
|
44
|
+
}
|
|
45
|
+
setCategories(categories) {
|
|
46
|
+
this.nativeCommandsSender.setCategories(categories);
|
|
47
|
+
}
|
|
48
|
+
getBadgeCount() {
|
|
49
|
+
return this.nativeCommandsSender.getBadgeCount();
|
|
50
|
+
}
|
|
51
|
+
setBadgeCount(count) {
|
|
52
|
+
this.nativeCommandsSender.setBadgeCount(count);
|
|
53
|
+
}
|
|
54
|
+
cancelLocalNotification(notificationId) {
|
|
55
|
+
this.nativeCommandsSender.cancelLocalNotification(notificationId);
|
|
56
|
+
}
|
|
57
|
+
cancelAllLocalNotifications() {
|
|
58
|
+
this.nativeCommandsSender.cancelAllLocalNotifications();
|
|
59
|
+
}
|
|
60
|
+
isRegisteredForRemoteNotifications() {
|
|
61
|
+
return this.nativeCommandsSender.isRegisteredForRemoteNotifications();
|
|
62
|
+
}
|
|
63
|
+
checkPermissions() {
|
|
64
|
+
return this.nativeCommandsSender.checkPermissions();
|
|
65
|
+
}
|
|
66
|
+
removeAllDeliveredNotifications() {
|
|
67
|
+
this.nativeCommandsSender.removeAllDeliveredNotifications();
|
|
68
|
+
}
|
|
69
|
+
removeDeliveredNotifications(identifiers) {
|
|
70
|
+
return this.nativeCommandsSender.removeDeliveredNotifications(identifiers);
|
|
71
|
+
}
|
|
72
|
+
getDeliveredNotifications() {
|
|
73
|
+
return this.nativeCommandsSender.getDeliveredNotifications();
|
|
74
|
+
}
|
|
75
|
+
refreshToken() {
|
|
76
|
+
this.nativeCommandsSender.refreshToken();
|
|
77
|
+
}
|
|
78
|
+
setNotificationChannel(notificationChannel) {
|
|
79
|
+
this.nativeCommandsSender.setNotificationChannel(notificationChannel);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.Commands = Commands;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|