Larry King
Larry King

Reputation: 449

Displaying web page in Ionic V4 app - inconsistencies

I have used the following for years to display an external website in my own Ionic apps with no issues:

<a href="https://www.golftocs.com/" style="color: #ffffff; font-size: 18px;">
  golfTOCS
</a>

I recently inherited an Ionic V4 app that uses cordova-plugin-inappbrowser to display external websites, per the plug-in documentation. I try to use my already working solution, i.e. without in app browser, from my apps so I can potentially remove the in app browser plugin. However this does not work!

When I make this change the app transitions to the external website but it is not completely functional and there is no back to app button at top left. Same operation on both Android and iOS. This is driving me crazy and I just want to understand why.

Both apps are on Ionic V4 production, Angular 7.x.x, and pretty much latest version of all plugins. I have compared node_modules, plugins, config.xml. I have tried swapping the urls between working and not working apps - not dependent on urls.

Any suggestions would be greatly appreciated.

Upvotes: 0

Views: 90

Answers (1)

Alex Steinberg
Alex Steinberg

Reputation: 1466

From the Cordova docs, <allow-intent> controls which sites your app can navigate to externally and <allow-navigation> controls which sites your app can navigate to internally, i.e. within the WebView. Try setting <allow-intent href="*" /> to see if it solves your problem in the new app, as well as <allow-navigation href="*" /> as per your comment.

Both apps probably have cordova-plugin-whitelist pre-installed, so those docs might be able to help.

Also, begin with a generous Content Security Policy as that can add an additional layer of complication (MDN docs here).

Once working, be sure to make your policies as strict as possible and as loose as necessary.

Upvotes: 0

Related Questions