Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ var WebView = React.createClass({
* user can change the scale
*/
scalesPageToFit: PropTypes.bool,
externalHTTPEnabled: PropTypes.bool
},

getInitialState: function() {
Expand Down Expand Up @@ -168,6 +169,7 @@ var WebView = React.createClass({
onLoadingFinish={this.onLoadingFinish}
onLoadingError={this.onLoadingError}
scalesPageToFit={this.props.scalesPageToFit}
externalHTTPEnabled={this.props.externalHTTPEnabled}
/>;

return (
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions React/Views/RCTWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTWebViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down