Origin whitelist fails on iOS for iframes
See original GitHub issueHi,
i use react-native-webview 6.9.0 with react 59.5 to embed a page that contains an iframe with a standard google maps embed like this:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d1666.5345895801888!2d-111.841501241774!3d33.34314243590285!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x872ba9c40ac5d6f9%3A0x83f80f281a875961!2sReact+Defense!5e0!3m2!1sen!2sde!4v1565892032668!5m2!1sen!2sde" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
I have set originWhitelist
to my website root.
With android, as expected you can navigate within my project and clicking external URLs will be handled by the OS.
With iOS (12.4) Safari gets opened immediately, loading the iframe src URL (the google embed page).
Is this a known problem for iframes?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top GitHub Comments
I solved the problem In the node modules file we open the apple file inside the react-native-webwiew file and open RNCWebView.m We need to make some additions here if (_onShouldStartLoadWithRequest) { NSMutableDictionary<NSString *, id> *event = [self baseEvent]; [event addEntriesFromDictionary: @{ @“url”: (request.URL).absoluteString, @“mainDocumentURL”: (request.mainDocumentURL).absoluteString, @“navigationType”: navigationTypes[@(navigationType)] }]; if (![self.delegate webView:self shouldStartLoadForRequest:event withCallback:_onShouldStartLoadWithRequest]) { decisionHandler(WKNavigationActionPolicyCancel); return; } }
such lines if (_onShouldStartLoadWithRequest) { NSMutableDictionary<NSString *, id> *event = [self baseEvent]; [event addEntriesFromDictionary: @{ @“url”: (request.URL).absoluteString, @“mainDocumentURL”: (request.mainDocumentURL).absoluteString, @“navigationType”: navigationTypes[@(navigationType)] }]; if (!navigationAction.targetFrame.isMainFrame){ decisionHandler(WKNavigationActionPolicyAllow); return; } if (![self.delegate webView:self shouldStartLoadForRequest:event withCallback:_onShouldStartLoadWithRequest]) { decisionHandler(WKNavigationActionPolicyCancel); return; } } we have to change it this way
it will not show if you make this change while the project is running. It is necessary to close the Metro control panel and run it again by saying npx react-native start @christianbermejo