import { NativeModules } from 'react-native'; import { Notification, NotificationCategory, NotificationPermissions } from '../interfaces/Notification'; interface NativeCommandsModule { getInitialNotification(): Promise; localNotification(notification: Notification, id: string): void; requestPermissions(): void; abandonPermissions(): void; registerPushKit(): void; getBadgeCount(): Promise; setBadgeCount(count: number): void; cancelLocalNotification(notificationId: string): void; cancelAllLocalNotifications(): void; isRegisteredForRemoteNotifications(): Promise; checkPermissions(): Promise; removeDeliveredNotifications(identifiers: Array): void; removeAllDeliveredNotifications(): void; setCategories(categories: [NotificationCategory?]): void; } export class NativeCommandsSender { private readonly nativeCommandsModule: NativeCommandsModule; constructor() { this.nativeCommandsModule = NativeModules.RNBridgeModule; } sendLocalNotification(notification: Notification, id: string) { return this.nativeCommandsModule.localNotification(notification, id); } getInitialNotification() { return this.nativeCommandsModule.getInitialNotification(); } requestPermissions() { return this.nativeCommandsModule.requestPermissions(); } abandonPermissions() { return this.nativeCommandsModule.abandonPermissions(); } registerPushKit() { return this.nativeCommandsModule.registerPushKit(); } setCategories(categories: [NotificationCategory?]) { this.nativeCommandsModule.setCategories(categories); } getBadgeCount(): Promise { return this.nativeCommandsModule.getBadgeCount(); } setBadgeCount(count: number) { this.nativeCommandsModule.setBadgeCount(count); } cancelLocalNotification(notificationId: string) { this.nativeCommandsModule.cancelLocalNotification(notificationId); } cancelAllLocalNotifications() { this.nativeCommandsModule.cancelAllLocalNotifications(); } isRegisteredForRemoteNotifications(): Promise { return this.nativeCommandsModule.isRegisteredForRemoteNotifications(); } checkPermissions() { return this.nativeCommandsModule.checkPermissions(); } removeAllDeliveredNotifications() { return this.nativeCommandsModule.removeAllDeliveredNotifications(); } removeDeliveredNotifications(identifiers: Array) { return this.nativeCommandsModule.removeDeliveredNotifications(identifiers); } }