NativeCommandsSender.ts 996 Bytes
Newer Older
yogevbd's avatar
yogevbd committed
1 2 3 4 5 6 7
import { NativeModules } from 'react-native';
import { Notification } from '../interfaces/Notification';

interface NativeCommandsModule {
  getInitialNotification(): Promise<any>;
  localNotification(notification: Notification, id: string): Promise<Notification>;
  requestPermissionsWithCategories(categories: any): Promise<any>;
yogevbd's avatar
yogevbd committed
8
  abandonPermissions(): Promise<any>;
yogevbd's avatar
yogevbd committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
}

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.requestPermissionsWithCategories([]);
  }
yogevbd's avatar
yogevbd committed
28 29 30 31

  abandonPermissions() {
    return this.nativeCommandsModule.abandonPermissions();
  }
yogevbd's avatar
yogevbd committed
32
}