@@ -12,19 +12,22 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
12
12
}
13
13
14
14
private _callback : ( result ?) => void ;
15
+ private _errorCallback : ( result ?) => void ;
15
16
16
17
private _width : number ;
17
18
private _height : number ;
18
19
private _keepAspectRatio : boolean ;
19
20
private _saveToGallery : boolean ;
20
21
21
- public initWithCallback ( callback : ( result ?) => void ) : UIImagePickerControllerDelegateImpl {
22
+ public initWithCallback ( callback : ( result ?) => void , errorCallback : ( result ? ) => void ) : UIImagePickerControllerDelegateImpl {
22
23
this . _callback = callback ;
24
+ this . _errorCallback = errorCallback ;
23
25
return this ;
24
26
}
25
27
26
- public initWithCallbackAndOptions ( callback : ( result ?) => void , options ?) : UIImagePickerControllerDelegateImpl {
28
+ public initWithCallbackAndOptions ( callback : ( result ?) => void , errorCallback : ( result ? ) => void , options ?) : UIImagePickerControllerDelegateImpl {
27
29
this . _callback = callback ;
30
+ this . _errorCallback = errorCallback ;
28
31
if ( options ) {
29
32
this . _width = options . width ;
30
33
this . _height = options . height ;
@@ -117,6 +120,7 @@ class UIImagePickerControllerDelegateImpl extends NSObject implements UIImagePic
117
120
imagePickerControllerDidCancel ( picker ) : void {
118
121
picker . presentingViewController . dismissViewControllerAnimatedCompletion ( true , null ) ;
119
122
listener = null ;
123
+ this . _errorCallback ( new Error ( "cancelled" ) ) ;
120
124
}
121
125
}
122
126
@@ -144,13 +148,13 @@ export let takePicture = function (options): Promise<any> {
144
148
145
149
if ( reqWidth && reqHeight ) {
146
150
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 } ) ;
148
152
} else if ( saveToGallery ) {
149
153
listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallbackAndOptions (
150
- resolve , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio } ) ;
154
+ resolve , reject , { saveToGallery : saveToGallery , keepAspectRatio : keepAspectRatio } ) ;
151
155
}
152
156
else {
153
- listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallback ( resolve ) ;
157
+ listener = UIImagePickerControllerDelegateImpl . new ( ) . initWithCallback ( resolve , reject ) ;
154
158
}
155
159
imagePickerController . delegate = listener ;
156
160
0 commit comments