diff --git a/Libraries/Components/WebView/WebView.ios.js b/Libraries/Components/WebView/WebView.ios.js index a3d457bfdb6f2d..12bf1954ab8683 100644 --- a/Libraries/Components/WebView/WebView.ios.js +++ b/Libraries/Components/WebView/WebView.ios.js @@ -107,6 +107,7 @@ var WebView = React.createClass({ * user can change the scale */ scalesPageToFit: PropTypes.bool, + externalHTTPEnabled: PropTypes.bool }, getInitialState: function() { @@ -168,6 +169,7 @@ var WebView = React.createClass({ onLoadingFinish={this.onLoadingFinish} onLoadingError={this.onLoadingError} scalesPageToFit={this.props.scalesPageToFit} + externalHTTPEnabled={this.props.externalHTTPEnabled} />; return ( diff --git a/React/Views/RCTWebView.h b/React/Views/RCTWebView.h index fdb192a39f3f31..ed1e782c9b25c7 100644 --- a/React/Views/RCTWebView.h +++ b/React/Views/RCTWebView.h @@ -23,6 +23,7 @@ extern NSString *const RCTJSNavigationScheme; @property (nonatomic, assign) UIEdgeInsets contentInset; @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets; @property (nonatomic, copy) NSString *injectedJavaScript; +@property (nonatomic, assign) BOOL externalHTTPEnabled; - (void)goForward; - (void)goBack; diff --git a/React/Views/RCTWebView.m b/React/Views/RCTWebView.m index 46d47c8955fee7..29fc42b77883bf 100644 --- a/React/Views/RCTWebView.m +++ b/React/Views/RCTWebView.m @@ -142,6 +142,11 @@ - (void)refreshContentInset - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { + if ( _externalHTTPEnabled && navigationType == UIWebViewNavigationTypeLinkClicked && + [request.URL.scheme hasPrefix:@"http"]) { + [[UIApplication sharedApplication] openURL:[request URL]]; + return NO; + } if (_onLoadingStart) { // We have this check to filter out iframe requests and whatnot BOOL isTopFrame = [request.URL isEqual:request.mainDocumentURL]; diff --git a/React/Views/RCTWebViewManager.m b/React/Views/RCTWebViewManager.m index 8779a970baa81d..478af75ad4d41e 100644 --- a/React/Views/RCTWebViewManager.m +++ b/React/Views/RCTWebViewManager.m @@ -34,6 +34,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock); RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock); RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock); +RCT_EXPORT_VIEW_PROPERTY(externalHTTPEnabled, BOOL); - (NSDictionary *)constantsToExport {