import { Application , Utils } from '@nativescript/core' ; const CONFIRMATION_ACTIVITY_REQUEST_CODE = 5673 ; param options export const confirm = ( options ) => { return new Promise ( ( resolve , reject ) => { const intent = new android . content . Intent ( Utils . android . getApplicationContext ( ) , ( com as any ) . github . bradmartin . smartwearos . ConfirmationActivity . class ) ; intent . putExtra ( 'MESSAGE' , options . message ) ; if ( options . title ) { intent . putExtra ( 'TITLE' , options . title ) ; } if ( options . autoCloseTime ) { intent . putExtra ( 'AUTO_CLOSE_TIME' , options . autoCloseTime ) ; } const activity = Application . android . foregroundActivity || Application . android . startActivity ; activity . startActivityForResult ( intent , CONFIRMATION_ACTIVITY_REQUEST_CODE ) ; activity . onActivityResult = ( requestCode , resultCode , data ) => { if ( requestCode === CONFIRMATION_ACTIVITY_REQUEST_CODE ) { if ( resultCode === android . app . Activity . RESULT_OK ) { return resolve ( true ) ; } else if ( resultCode === android . app . Activity . RESULT_CANCELED ) { return resolve ( false ) ; } else { return resolve ( null ) ; } } } ; } ) ; } ; export interface ConfirmOptions { /**
     * The message to show for failure/error action.
     */ message : string ; /**
     * The title of the dialog
     */ title ? : string ; /**
     * Time in seconds to auto close the confirm dialog.
     * Will result in the promise resolving false if user makes no selection after the provided time.
     */ autoCloseTime ? : number ; }