I have a list of items, when a user clicks on a specific item I want to open the phone so he can make a phone call to a specific number, however before that I want to send a notification to my server to indicate that the user clicked on the item.
This is how my html looks like:
<ion-item ng-repeat="order in orders">
<img width="50" height="50" src="img/phone.ico" />
The a href works great and opens the phone. The method makePhoneCall is also executed before the phone is opened, the problem is that when I execute http request inside this method it is canceled, because the device switches to phone application. When I remove the href element the request is finished successfully.
Is there a way to open phone application from code NOT using href ? or any idea how can I delay the href to open the phone only after http request finished ?
Have you tried
Didn’t test but something along those lines might work for you if you call one of those methods from makePhoneCall after the http request succeeds.
Let me know if it works
window.open should do the trick.
This works great ! Thanks.
I’m also trying but cannot get trough on the iOS Simulator.
tried both – for the moment with a fixed phone number:
<a class="tab-item" href="#" onclick="window.open('tel:0039340123456')"><i class="icon ion-ios-telephone-outline"></i></a>
but I get an error in the console:
2015-04-01 15:14:05.459 InRuTouMapp[6069:1676584] CDVWebViewDelegate: Navigation started when state=1 2015-04-01 15:14:05.460 InRuTouMapp[6069:1676584] Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1 2015-04-01 15:14:05.460 InRuTouMapp[6069:1676584] Failed to load webpage with error: The URL can’t be shown
OS: Mac OS X Yosemite Node Version: v0.10.36 Cordova CLI: 4.3.0 Ionic CLI Version: 1.3.18 Xcode version: Xcode 6.2 Build version 6C131e ios-sim version: 3.1.1 ios-deploy version: Not installed
Can anyone please offer a solution?
Thanks in advance!
is it possible that it works only on real devices and not on the simulators?
Yup, this will only work on a real device.
just found out that on the a real iPhone all these works as expected:
the last two requires:
while on a real Android (4.3 Jelly Bean) the mailto opens an email within the app window – however it’s possible to return to the app by tapping on the back button
Android update: I tried to send the email and after the app sends it out it properly returns to the main app screen!
First, we want to install Cordova native plugin in CLI
$ ionic cordova plugin add call -number
$ npm install --save @ionic-native/call-number
Fellow the step blow website. I hope it will be helpful to you.