Cordova IOS Can't Open Links
I have a cordova project that is being compiled for both Android and iOS. I have some links in it that open a website in the system browser, e.g.:
window.open('https://example.com', '_system'); cordova.InAppBrowser.open('httos://example.com', '_system');
This works fine on Android, however nothing happens on iOS, not even '_blank'.
I also tried adding the inappbrowser plugin (https://github.com/apache/cordova-plugin-inappbrowser) like others recommended, but nothing changed when I implemented that.
Any ideas on how to open links in the system browser on iOS? Every source on google just says add the inappbrowser plugin, or to just use '_system' (but that's what I've been doing!).
I don't believe it to be an issue with my whitelist, since it works fine on android, and my app can load resources fine from the internet on iOS as well. Everything works except for opening links on iOS.
UPDATE: calling cordova.InAppBrowser.open() works when called from the onDeviceReady event, but doesn't work outside of the event. I even tried setting window.open, but that didn't work.
After some ruthless digging on some forums, I found this post on the ionic forums: https://forum.ionicframework.com/t/cordova-inappbrowser-plugin-stopped-working-in-ios-10/64361/9
By changing my content security policy to:
<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data:; default-src * 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">
It worked! I would however like to better understand why this CSP works as opposed to the commonly recommend 'gap://ready' that everyone says to use.
- → Function Undefined in Axios promise
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Click to navigate on mobile devices
- → Playing Video - Server is not correctly configured - 12939
- → How to allow api access to android or ios app only(laravel)?
- → Axios array map callback
- → Access the Camera and CameraRoll on Android using React Native?
- → Update React [Native] View on Day Change
- → Shopify iOS SDK - issue converting BuyProductVariant to BuyProduct
- → BigCommerce and shopify API
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → React Native - Differences between Android and IOS
- → What is the difference between React Native and React?