question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Origin whitelist fails on iOS for iframes

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
ibrahimmkaracommented, Jul 9, 2020

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

0reactions
ibrahimmkaracommented, Jul 15, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Origin whitelist fails on iOS for iframes · Issue #785
Hi, 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...
Read more >
iOS not loading iframe content
I am trying to get iframes to work on iOS using Cordova CLI 6.2.0 and PhoneGap Desktop ... <gap:plugin name="org.apache.cordova.whitelist" source="npm" />.
Read more >
Loading external webpages in iFrames
Hi, I'm trying to load a page in an iFrame, but the iFrame just remains blank. I tried links in my local network,...
Read more >
Problems with iframes on cordova apps
I've tried several things I've seen here and in other websites such as making changes to the whitelist, adding parameters to the meta...
Read more >
frame-ancestors in CSP ⟶ Allowing / Blocking iframes from ...
How to use the CSP frame-ancestors directive in a Content-Security-Policy header to allow or block the page from being loaded within frames or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found