Cordova Using allow-navigation impacts allow-intent on iOS - javascript

In my app I have some links with the tag <a href=""> and also with javascript with the code below.
let url = param;
window.open(url, '_system');
My config.xml is configured as below, and opening links works perfectly, when clicking on a link or executing the window.open function, it opens Safari and the URL together.
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
However, as I need to display some videos from YouTube and Vimeo (iframe), I needed to add the allow-navigation tag, but when I do that, the allow-intent setting is ignored and all links start opening inside the app.
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="https://*youtube.com/*"/>
<allow-navigation href="https://*vimeo.com/*" />
I use https://*/* because the user can make infinite URLs available and so it would be interesting for him to be able to open any one.
I don't know if this is a bug or my fault.
If I used only allow-navigation I would have to have some workaround in the code to detect each link that comes in dynamic texts created by users and assign an onClick event to use the inAppBrowser and force it to use the _system.
But this kind of code I don't know how to do.
Cordova: 11.1.0
Cordova iOS: 6.2.0

Related

Phonegap inappbrowser do not load, shows blank page

This is phonegap main file www/index.html I want to load my site like a native app, the script:
//var ref = cordova.InAppBrowser.open('http://website.com/page/index.php', '_self', 'location=no');
document.addEventListener("deviceready", function(){
window.open = cordova.InAppBrowser.open('http://website.com/page/index.php', '_self', 'location=no');
},true);
</script>
my phonegap config.xml file
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
also my website has enable in all pages
header('Access-Control-Allow-Origin: *');
the website in the script is not my website at all because I am running it on localhost, I tested the website in same network with phone browser and it works just fine, but when I try to load via phone gap app it shows blank page
your code is changing the prototype default for windows.open(), not actually opening anything;
what you need is:
window.open = cordova.InAppBrowser.open;//change default prototype to cordova
var ref = cordova.InAppBrowser.open(url, target, options);//inappbrwoser reference
then you can do ref.close(),show(),hide() etc.
you can also addEventListener

Include external javascript code in cordova app

I tried to include external javascript code in my cordova app but it doesn't work.
My code as following:
<script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="http://website.com/api/scripts.js"></script>
My whitelist script as following:
<allow-navigation href="*" />
<allow-intent href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
it's better to load the jQuery script from the app library instead external (unlike in web), makes the loading faster.
regarding the script add,
<access origin="https://*.website.com/api/scripts.js" launch-external="yes"/> check if it fixes the build.

Twilio video room not working in cordova hybrid app

Twilio video room chat not working in cordova hybrid app.local vido load in mobile but remote video not load in mobile app window . How to fix this error?
code is running without any error in all web browser.
we set all type of whitelist and intent and all
as follow
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<allow-intent href="market:*"/>
<allow-intent href="data:*"/>
<allow-intent href="*://*.ezhealthpal.com/*"/>
<allow-intent href="*://*.media.twiliocdn.com/*"/>
<allow-intent href="*://*.apis.google.com/*"/>
<allow-intent href="video:*"/>
<allow-intent href="audio:*"/>
<allow-intent href="blob:*"/>
<allow-intent href="*"/>
<allow-navigation href="*"/>

What is the right way of connect to a REST API with content security policy in a Phonegap/cordova Android APP

I have successfully developed a Phonegap hybrid App, it worked well on emulators but unable to post to a remote server when installed on android device. I configured white list plugin and my config.xml contains
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*"/>
<allow-navigation href="http://*/*"/>
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
and my index page contains
<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src *; connect-src *">
I am using Cordova 5.3.3
but yet nothing seems to work.
Please can anybody tell me what I am doing wrong.
Thanks
Try the following
<plugin name="cordova-plugin-whitelist" source="npm" spec="1.1.0" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />
<preference name="permissions" value="none"/>
The white-listing configuration and the Content Security Policy I posted in my question are correct and sufficient to get an hybrid app deployed on android platform connected to a remote API.
The problem was the API itself, as the app does connected well with other API. Initially we are using a play framework to develop our API, which has some issue responding to client request on the hybrid APP.
We then create a PHP proxy script which gets the request from the client and passes same to the play server.
That is it.

Cordova: google maps v3 not showing on iOS

I am building a cordova app and i am stuck with a problem since three days.. I tried every thing i found on Stack or Google. My point is I can show a google map on android but not on iOS. There is just a grey div. On debug, when clicking on this div, I get this error : TypeError: undefined is not an object (evaluating 'a.x')
Another thing : I have a Gif loader that stay over the grey div, and it should go under the map div.
I am using gmap v3 with or without API key : same issue.
I copy my config.xml :
<?xml version='1.0' encoding='utf-8'?>
<widget id="co.brandyapp.applitest8" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>applitest8</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*.google.com" />
<access origin="*.gstatic.com" />
<access origin="*.googleapis.com" />
<access origin="*.brandyapp.co" />
<allow-navigation href="http://*.google.com" />
<allow-navigation href="http://*.googleapis.com/*" />
<allow-navigation href="http://*.gstatic.com/*" />
<allow-navigation href="http://*.brandyapp.co/*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
The strange thing is I get the same issue with this tuto : http://www.christianengvall.se/phonegap-and-google-maps/
Thank you for your help ! This issue is driving me crazy ! :)

Categories

Resources