import { Linking } from 'react-native' ; import { DialogDelegate } from '../dialog/DialogDelegate' ; export class LinkingDelegate { public dialogDelegate : DialogDelegate ; public constructor ( dialogDelegate ) { this . dialogDelegate = dialogDelegate ; } public openLink ( link ) { Linking . canOpenURL ( link ) . then ( ( supported ) : void => { if ( supported ) { Linking . openURL ( link ) ; } else { this . showCannotOpenLinkError ( ) ; } } , ( ) : void => this . showCannotOpenLinkError ( ) ) ; } private showCannotOpenLinkError ( ) { this . dialogDelegate . show ( { message : 'Cannot open link. Please check internet connection' , showCloseButton : true , } ) ; } }