@@ -12,19 +12,22 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
1212 }
1313
1414 private _callback : ( result ?) => void ;
15+ private _errorCallback : ( result ?) => void ;
1516
1617 private _width : number ;
1718 private _height : number ;
1819 private _keepAspectRatio : boolean ;
1920 private _saveToGallery : boolean ;
2021
21- public initWithCallback ( callback : ( result ?) => void ) : UIImagePickerControllerDelegateImpl {
22+ public initWithCallback ( callback : ( result ?) => void , errorCallback : ( result ? ) => void ) : UIImagePickerControllerDelegateImpl {
2223 this . _callback = callback ;
24+ this . _errorCallback = errorCallback ;
2325 return this ;
2426 }
2527
26- public initWithCallbackAndOptions ( callback : ( result ?) => void , options ?) : UIImagePickerControllerDelegateImpl {
28+ public initWithCallbackAndOptions ( callback : ( result ?) => void , errorCallback : ( result ? ) => void , options ?) : UIImagePickerControllerDelegateImpl {
2729 this . _callback = callback ;
30+ this . _errorCallback = errorCallback ;
2831 if ( options ) {
2932 this . _width = options . width ;
3033 this . _height = options . height ;
@@ -117,6 +120,7 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
117120 imagePickerControllerDidCancel ( picker ) : void {
118121 picker . presentingViewController . dismissViewControllerAnimatedCompletion ( true , null ) ;
119122 listener = null ;
123+ this . _errorCallback ( new Error ( "cancelled" ) ) ;
120124 }
121125}
122126
@@ -144,13 +148,13 @@ export let takePicture = function (options): Promise<any> {
144148
145149 if ( reqWidth && reqHeight ) {
146150 listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallbackAndOptions (
147- resolve , { width : reqWidth , height : reqHeight , keepAspectRatio : keepAspectRatio , saveToGallery : saveToGallery } ) ;
151+ resolve , reject , { width : reqWidth , height : reqHeight , keepAspectRatio : keepAspectRatio , saveToGallery : saveToGallery } ) ;
148152 } else if ( saveToGallery ) {
149153 listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallbackAndOptions (
150- resolve , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio } ) ;
154+ resolve , reject , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio } ) ;
151155 }
152156 else {
153- listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallback ( resolve ) ;
157+ listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallback ( resolve , reject ) ;
154158 }
155159 imagePickerController . delegate = listener ;
156160
0 commit comments