Skip to content

Commit 0b51df4

Browse files
committed
added modal completion handler
1 parent d7e5a8f commit 0b51df4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

RCTBrowser.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ @implementation RCTBrowser
66

77
RCT_EXPORT_MODULE()
88

9-
RCT_EXPORT_METHOD(presentUrl:(NSString *)url withOptions:(NSDictionary *)options) {
9+
RCT_EXPORT_METHOD(presentUrl:(NSString *)url
10+
withOptions:(NSDictionary *)options
11+
modalCompletion:(RCTResponseSenderBlock)modalCompletionHandler) {
1012

1113
TOWebViewController *webVC = [[TOWebViewController alloc] initWithURLString:url];
1214

@@ -31,8 +33,6 @@ @implementation RCTBrowser
3133
webVC.disableContextualPopupMenu = ([obj isEqual: @(YES)]);
3234
} else if ([key isEqualToString:@"hideWebViewBoundaries"]) {
3335
webVC.hideWebViewBoundaries = ([obj isEqual: @(YES)]);
34-
} else if ([key isEqualToString:@"modalCompletionHandler"]) {
35-
// TODO: turn this into a callback
3636
} else if ([key isEqualToString:@"shouldStartLoadRequestHandler"]) {
3737
// TODO: turn this into a callback
3838
} else if ([key isEqualToString:@"buttonTintColor"]) {
@@ -42,6 +42,10 @@ @implementation RCTBrowser
4242
}
4343
}];
4444

45+
webVC.modalCompletionHandler = ^(void) {
46+
modalCompletionHandler(@[[NSNull null]]);
47+
};
48+
4549
UIViewController *rootVC = [[UIApplication sharedApplication] keyWindow].rootViewController;
4650
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:webVC];
4751

index.ios.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ var Browser = NativeModules.Browser;
1010

1111
var RCTBrowserExport = {
1212
open: function(url, options={}) {
13-
Browser.presentUrl(url, options);
13+
Browser.presentUrl(url, options, function(err) {
14+
if (options.modalCompletionHandler) {
15+
options.modalCompletionHandler();
16+
}
17+
});
1418
},
1519
};
1620

0 commit comments

Comments
 (0)