My app is built with Cordova 10. I added platform Android.
It calls Web service SOAP. But it's not connect to the web server.
I tried few tests such as add an iframe including a https url. It works fine.
But nothing display with an in an iframe including a http url.
I think my app refuses http. This what i have in my config.xml.
As you can see, i allow everything. What's wrong ?
<widget id=....
<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:*" />
</widget>
You could always try to use clear text traffic, see
https://www.npmjs.com/package/cordova-plugin-enable-cleartext-traffic
But depending on what you're trying to do, as the webview is now served using https, it might reject loading resources over http.
Related
I have an Angular app that works fine in browser then used Cordova to make an apk from that, when I check this app the login is visible but when I try to enter I get this error:
I tried several solutions from other posts:
1.- android:usesCleartextTraffic="true" in AndroidManifest.xml
2.- cleartextTrafficPermitted in a network_security_config.xml file and including it in AndroidManifest.xml
3.- Added all this in config.xml:
<access origin="*" />
<allow-navigation 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:*" />
4.- Added a configNotWorking.xml file
5.- remove platform (android) and adding it again
But none of them seems to be working
What could be the issue and how can I solve it?
Thanks.
Ps: Im kinda new with Cordova but I used it a couple of times for html5 apps with no problem
I have an angular app which I try to wrap in a cordova application for android. But I fail at whitelisting the requests against a server, when the cordova app on android.
When testing the cordova application as a browser application, there are no problems.
I've already read many articles and posts regarding the whitelisting behaviour on cordova, but without any results.
I'm using cordova 10. As I read, I should not use the cordova-plugin-whitelist, because in this version this plugin is already integrated in the main framework. The configuration in config.xml was already generated automatic when creating the project.
Here is my config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="de.acme.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>appname</name>
<description>description</description>
<author email="user#mail.de" href="https://mail.de">author</author>
<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:*" />
<platform name="android">
<access origin="*" />
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
As you see, the tag with the access origin is available.
I have no plugins installed. But I also tried to install the cordova-plugin-whitelist. But this also makes no difference.
The requests in Angular are standard GET requests with the HTTPClient. But also other requests does not work. For example the embedding of google fonts.
The server, I want to access with my GET requests is a server in my LAN with the following address: 192.168.178.5:4003 (specific port!)
In Logcat I receive this error message:
I/chromium: [INFO:CONSOLE(1)] "request: http://192.168.178.5:4003/api/audiobooks/tags", source: file:///android_asset/www/main.a7f87f00e27ff7637d70.js (1)
W/SystemWebViewClient: URL blocked by whitelist: http://192.168.178.5:4003/api/audiobooks/tags
I think, this is just a small configuration problem. But I have no idea, where I should look for a correct solution.
Thank you
If you use HTTP, you might need to allow Android to use clear text traffic. See: https://cordova.apache.org/docs/en/dev/guide/platforms/android/index.html#android-quirks
If you are on cordova-android 10 make sure to use the latest version (10.1.0), as it contains important bug fixes.
I have config the config.xml in android cordova to let all the domain can be loaded.like this:
<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:*" />
And the web page that i need to load has CSP configuration like this:frame-ancestors 'self' *.sc.com *.standardchartered.com *.standardchartered.co.in *.standardchartered.co.th *.standardchartered.com.hk *.standardchartered.com.my *.standardchartered.com.sg *.standardchartered.co.id *.standardchartered.com.tw
By using Charles to catch response that i find the http status is 200. Even more amazing thing is this problem only be occurred in android, ios and web do not appear.
Seeking for your help, please...
Try like this:
You are loading url into an iframe in the main web view, which requires you to allow access to that content in the config.xml file.
<allow-navigation href="http://example.com/*" />
Refer this url: https://cordova.apache.org/docs/en/latest/guide/appdev/whitelist/
My Ionic is working with socket.io in a webview. But when I try to compile my app to android, it seems that socket.io cannot connect to my nodejs server.
As I console everything to my node server for connection events, it doesn't trigger the connection event as seen below:
io.on('connection',function(socket){
console.log('My socket id is '+socket.id);
});
My node console works properly when I try to run the app in a browser. But using the android app extracted from cordova it seems it cannot connect.
UPDATE: this is my config.xml file in my app
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.pagemanager" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>PageManager</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" />
<plugin name="cordova-plugin-whitelist" spec="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>
i already solved my problem. what i did is to make it work in a simulator so that i can debug or see easily the errors. and i fount out the the path in mobile is always starting in file:// blah blah when i use the native script code to get current path. and thats why its not connecting to my Nodejs Server. and everything is fixed now. thank you! SO'ers.
I'm stuck trying to troubleshoot a problem: Google Analytics is not registering any data from my app.
I've tried several plugins to no avail. No data gets registered.
I am executing the plugin code inside the device ready function. The device ready function works properly, but no data is sent to Analytics.
Since no plugin worked, I looked for a way to do it without a plugin. A few sites suggested ways of getting Analytics to work without a plugin. Here's the code:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-3', {
'storage' : 'none',
'clientId' : device.uuid
});
ga('set', {
'appName' : 'My App',
'appId' : '1123456',
'appVersion' : '1.3',
'checkProtocolTask' : null
});
The device plugin is loaded and alert(device.uuid); does indeed show me a UUID for my device.
I tried this code with both web property and mobile app property, neither registers data. Many tutorials mention using a web property as a workaround. Web property requires a URL and the URL must match what you set in analytics. Using a web property as a solution may have worked in the past but it does not work for me. Is there a configuration I may have missed?
I also tested if my app was able to retrieve remote data, so I loaded an iframe in my app with no problem. So now I'm looking towards the config.xml, which uses the cordova whitelist plugin. Which explicit permissions do I need to set so that the app can send data to Google Analytics?
Here are my current settings:
<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-navigation 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:*" />
<platform name="android">
<allow-intent href="*" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
I've been testing on a Nexus 5. I'm using phonegap 5.3.1
Thank you so much,
- Dan