import { Injectable } from '@angular/core';
import { CordovaService } from './cordova.service';

declare const cordova;

export type NotificationParam = {
  id?: number;
  title: string;
  message: string;
  callback?: Function;
  callbackData?: Object;
};

@Injectable({
  providedIn: 'root',
})
export class ClipboardService {
  constructor(private cordovaService: CordovaService) {}

  copy(text: string): Promise<void> {
    if (this.cordovaService.isOnApp()) {
      return this.cordovaService.copyClipboard(text);
    } else {
      return navigator.clipboard.writeText(text);
    }
  }
}
