Unable to call or email from mobile app - android

I'm working in a windows 7 environment using Cordova 6.4.0 to assemble a Android 6.1.0 app, and links in the app to send a call or email are not working. The app builds on my desktop, and the links work in Chrome. I am testing by loading the app using ADB 1.0.36 to my Galaxy S7.
I have the whitelist and inappbrowser plugins installed, and added the and in my config.xml as you see below. Slight changes were done to mask company information.
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.app" version="3.0" android-versionCode="3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>AppName</name>
<description>
App Description
</description>
<author email="email#company.com" href="https://www.example.com">
Author Name
</author>
<content src="index.html" />
<access launch-external="yes" origin="tel:*" />
<access launch-external="yes" origin="mailto:*" />
<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:*" />
<preference name="android-minSdkVersion" value="14"/>
<platform name="android">
<icon density="ldpi" src="assets/icons/android/ldpi.png" />
<icon density="mdpi" src="assets/icons/android/mdpi.png" />
<icon density="hdpi" src="assets/icons/android/hdpi.png" />
<icon density="xhdpi" src="assets/icons/android/xhdpi.png" />
<icon density="xxhdpi" src="assets/icons/android/xxhdpi.png" />
<icon density="xxxhdpi" src="assets/icons/android/xxxhdpi.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-whitelist" spec="~1.3.0" />
<engine name="android" spec="~6.1.0" />
</widget>
Here's an example of the links that are not working.
<div class="cuboxes">
<h2>Group list</h2>
<h3>( <span>800.555.5555</span> )</h3>
Call Us
E-Mail Us
</div>
I've tried changing the phone number format (removing the "-" or adding a "+" at the start of the number), and a number of other configuration changes. This app was built from scratch, and the web pages were added from the previous version of the app. The old version does not build as it does not use gradle.
Any help would be appreciated.

tel: phone_number
Calls the entered
phone number. Valid telephone numbers
as defined in the IETF RFC 3966 are
accepted. Valid examples include the
following:
* tel:2125551212
* tel: (212) 555 1212
The Android browser uses the Phone app to handle the “tel” scheme, as defined by RFC 3966.
Clicking a link like:
2125551212
on Android will bring up the Phone app and pre-enter the digits for 2125551212 without autodialing.
Have a look to RFC3966
UPDATE
see tel link android not working (Galaxy S5)
It seems you need to add a permission, do you have this set?
<access origin="tel:*" launch-external="yes" /> in your config.xml?
UPDATE 2
see “tel”, “sms”, and “mailto” no longer working in Android after upgrading to cordova 3.6.3
1. Add InAppBrowser plugin
**cordova plugin add org.apache.cordova.inappbrowser**
Create custom function in your JS file to open special links within the InApp browser
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
openNativeAppWindow: function(data) {
window.open(data, '_system');
}
};
The place where you are invoking special links like sms or tel then
pass on your custom url with data and let it open the native browser
window which in turn will push the native App to handle the special
urls.
Few example:
<br><br><input type="button" onClick="app.openNativeAppWindow('http://google.com')" value="Open Google"/>
<br><br><a onClick="app.openNativeAppWindow('geo://0,0?q=dallas')" data-rel="external">google maps</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=Bacau')">Geolocation Test</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=34.99,-106.61(Treasure)')">longitude & latitude with a string label</a>
<br><br><a onClick="app.openNativeAppWindow('geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA')">street address Test</a>
<br><br><a onClick="app.openNativeAppWindow('sms:2125551212')">SMS</a>
<br><br><a onClick="app.openNativeAppWindow('mms:2125551212')">MMS</a>
<br><br><a onClick="app.openNativeAppWindow('tel:2125551212')">Open Phone Dialer</a>

Try with this:
"tel://"
and "mailto://"

Related

W/SystemWebViewClient: URL blocked by whitelist

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.

webview - origin is not allowed by access-control-allow-origin (convert angular to mobile using cordova)

Im trying to create a angular app using Alfresco adf components (https://github.com/Alfresco/alfresco-ng2-components) and need to have a mobile app too, so i decide use cordova to generate apk.
I follow the following tutorial (https://medium.com/#nacojohn/convert-your-angular-project-to-mobile-app-using-cordova-f0384a7711a6) to generate my apk.
All seems to works fine, apk was generated and install in BlueStack, until i have to make login in my app.
Origin is not allowed by access-control-allow-origin
I know that i need to have a whitelist policy for navigating the application webview
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</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="*" />
<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="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-device" spec="^2.0.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<engine name="android" spec="^7.0.0" />
<engine name="ios" spec="^4.5.4" />
</widget>
index.html
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"
My angular web app have a dev-server proxy to fix the CORS problem
proxy.conf.json
{
"/alfresco": {
"target": "server-url",
"secure": false,
"changeOrigin": true
},
"/activiti-app": {
"target": "another-server-url",
"secure": false,
"changeOrigin": true
}
}
I dont know what i need to do more. Have i made something wrong? need to do something more?
Thanks
I think you should enable CORS in the Alfresco server, you can achieve that either by:
Including this dependency in you Alfresco extension.
Or by enabling CORS directly in the Tomcat server, full details can be found in the Tomcat documentation.
you have to enable CORS for details see Getting Started with Alfresco Application Development Framework
My problem was lack of configuration in app.config.json.
Instead of
"ecmHost": "http://{hostname}{:port}",
"bpmHost": "http://{hostname}{:port}"
I just need to set ecmHost and bpmHost to my servers and all works fine.
Thanks for helping guys

Cordova webview which is pointing to external site is not loading images

I have developed a website hosted in Apache (say xxx.com) which is working fine in all desktop/mobile browsers. It has few images which is hosted in self (xxx.com) and few images comes from other sites (yyy.com).
I created an Android App using Cordova which points to xxx.com. Deleted everything from Cordova_app/www folder. It works all fine, images (HTML img src) from self (xxx.com) loads fine but images from other domains (yyy.com) are not loading. What is the reason for images not to load from other domains?
Any help would be great
Below is the config.xml details
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.xxx" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>xxx</name>
<content src="https%3A%2F%2Fwww.xxx.com" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<preference name="Fullscreen" value="true" />
<preference name="Orientation" value="portrait" />
<allow-navigation href="https://*/*" />
<platform name="android">a
<allow-intent href="market:*" />
<icon src="res/icon/android/icon.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="^5.2.2" />
</widget>
Ok. I figured out the issue. Images from other domain was being called thru http not https. Since xxx.com is running in https, desktop and mobile browsers don't complain about it. But Webview blocks the content. "The content must be served over HTTPS".

Cordova app ajax call to localhost fails. ::ERR_CONNECTION_REFUSED

I've got an node.js (express) webapp running on localhost:3000. I am now trying to develop a mobile app using cordova.
I've got a route defined in my express app 'localhost:3000/tweets' which when called gets some tweets using twitter API and send them back as json object. Everythinngs works very fine using web app however I am struggling to make the same ajax call from a mobile app. To allow requests from other hosts I've added this to my edxpress app.js:
EDIT: i use cors middleware now:
app.use(cors());
In my cordova app:
meta tag:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="<id...>" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>appname</name>
<description>
A twitter search app.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</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>
<engine name="android" spec="^6.2.3" />
<plugin name="cordova-plugin-camera" spec="^2.4.1" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
</widget>
In the index.html file i link 'querySender.js' file at the bottom of body:
<script type="text/javascript" src="js/querySender.js"></script>
And finally, content of 'querySedner.js'
$(document).ready(function(){
$('#btn_send').on('click', function(){
console.log("app is now sending query!");
$.ajax({
type: 'POST',
url: 'http://127.0.0.1:3000/tweets',
data: {name:"test_name",lastname:"last_name"},
dataType:'json',
success: function(dataR){
var date = new Date();
console.log("POST success recorded at: ",date.getTime());
if (!dataR){
console.log("No Data received");
}else{
console.log("DataR: ",dataR);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("Status: " + textStatus+" error:"+ errorThrown);
},
timeout:5000
});
});
});
using WebStrom IDE i tried to run index.html in chrome (it runs it on localhost:63342) the request succeeds and data is delivered as expected.
however is emulate the app using android emulator when i press the button i get:
POST http://127.0.0.1:3000/tweets net::ERR_CONNECTION_REFUSED -- jquery-3.2.1.min.js:4
Basically. I'm running my node.js(express) server locally and would like to make ajax calls to it from cordova app on android emulator. What did I get wrong?
Okay, after frustrating hours of research I finally found that localhost or 127.0.0.1 refers just to emulator it self but not the computer it runs on. To fix this problem I just had to send the request to my computers (on which node.js server runs on) local ip. In my case local ip was 192.168.0.2 so I changed:
http://127.0.0.1:3000/tweets
to:
http://192.168.0.2:3000/tweets
And it seems to work now.

cordova angular cannot connect to socket.io

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.

Categories

Resources