Ionic2 phone call doesnt work on ios but on android (emu and devices) - ios

In my HTML file I am using a sliding-item and inside the options a button that calls a function:
<button secondary *ngIf="post.telefone" (click)="callIT('tel:'+post.telefone)">
<ion-icon name="call"></ion-icon>
Call
</button>
In the js file I have the function callIt() like:
callIT(passedNumber) {
window.location = passedNumber;
}
In my config.xml I added these line of code:
<access origin="*"/>
<access origin="tel:*" launch-external="yes"/>
This is working for android for both the emulator and on a device. In ios the call functionality isn`t working at all. Thanks to all for help

Related

Find path of local image of iOS project in Xamarin

I have an Image view like this:
<Image Source="{StaticResource AppIcon}" WidthRequest="80" HeightRequest="180" IsEnabled="True" ></Image>
Then i want to declare two different paths for either Android and iOS environment as:
<ResourceDictionary>
<OnPlatform x:TypeArguments="ImageSource" x:Key="AppIcon">
<On Platform="Android" Value="/Resources/drawable/splash_logo.png" />
<On Platform="iOS" Value="????" />
</OnPlatform>
</ResourceDictionary>
The problem is that i don't know how load my image from assets catalog in iOS project (android goes ok).
Can anyone help me?
if you are using native resources for Android and Asset Catalog for iOS then use only the name of file as source.
For example:
Files path in native projects:
Android - /resource/drawable-{size}/security.png
iOS - /Assets.xcassets/security.imageset/{name/size}.{png/pdf/json}
Using XAML:
<Image Source="security" />
Using C#:
Image.Source = "security";
(XAML) If the name of file is different for Android and iOS then use the OnPlatform + On tags but value will be still only the name without extension.
<On Platform="Android" Value="security" />
<On Platform="iOS" Value="devices" />
For C# you can use
if (Device.Platform == Device.Android)
Image.Source = "security";
else
Image.Source = "devices";

ng-include not working on iOS

Please help me on this issue, The below code is working fine on Android but not working on iOS. Its returning the error
XMLHttpRequest cannot load file:///var/containers/Bundle/Application/16B00380-9909-4D99-B4CA-B02DA895431B/Pilot%20Forge.app/www/templates/Menu.html.
Cross origin requests are only supported for HTTP
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>
<body>
<script type="text/javascript">
var Appclaim = angular.module("app_forge", []);
Appclaim.controller("claimController", function ($scope) {
$scope.MenuTemplate = {
Name: "Menu.html",
Url: "templates/Menu.html"
}
});
</script>
<form name="form" ng-app="app_forge" ng-controller="claimController">
<div>{{MenuTemplate.Name}}</div>
<div ng-include="MenuTemplate.Url"></div>
</form>
</body>
</html>
Just ran into this today - adding this to the config.xml under the ios platform section fixed it for me.
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
That and making sure you have the newest version of the iOS platform added / and that you are using WKWebView instead of the UIWebView.
Here's a GitHub issue that helped to find the answer:
Cordova not allowing https cross origin requests.
And here's a link to the article on Cordova's site:
UPDATED: How to handle the 'Deprecated API Usage - UIWebView' warning while uploading to the App Store
I guess iOS treats all file:// protocols as cross origin now. (iOS is proving to be a real pain to develop for.)

Allow call (and maps, and mail) in cordova

I've been struggling with this for a while. I'm trying to make a call after people press 'Call' from a popup. Funny thing is, that it goes straight to calling when they click the phone number. But when they hit 'Call', console returns:
ERROR Internal navigation rejected - <allow-navigation> not set for url='tel:06-83237516
Code:
Controller:
$scope.callPerson = function() {
var link = "tel:" + $scope.person.phonenumber;
var confirmTel = $ionicPopup.confirm({
title: $scope.person.phonenumber,
cancelText: 'Cancel',
okText: 'Call'
});
confirmTel.then(function(res) {
if (res) {
window.open(link);
} else {
console.log('cancel call');
}
});
}
Config.xml:
<access origin="*"/>
<allow-intent href="tel:*"/>
<allow-intent href="mailto:*"/>
<access origin="tel:*" launch-external="yes"/>
<access origin="mailto:*" launch-external="yes"/>
html:
<div ng-click="callPerson()"> {{person.phonenumber}}</div>
With Mail, it doesn't work at all, and returns an identical error.
Same for opening maps. It does work in the PhoneGap test app, but not when deployed.
Maps code:
$scope.openmaps = function() {
var address = $scope.person.adres + ", " + $scope.person.plaats;
var url = '';
if (ionic.Platform === 'iOS' || ionic.Platform === 'iPhone' || navigator.userAgent.match(/(iPhone|iPod|iPad)/)) {
url = "http://maps.apple.com/maps?q=" + encodeURIComponent(address);
} else if (navigator.userAgent.match(/(Android|BlackBerry|IEMobile)/)) {
url = "geo:?q=" + encodeURIComponent(address);
} else {
url = "http://maps.google.com?q=" + encodeURIComponent(address);
}
window.open(url);
};
May be it is too late but I want to comment so that other users couldn't face this issue.
Because I didn't find any working solution anywhere.
You need to add
<allow-navigation href="tel:*" /> in config.xml
I was facing same issue for mailto intent. It was working when I tried it directly
<a onclick="mailto:test#me.com">Email</a>
But I got an error when I tried to call it using javascript window.location.href = 'mailto:test#me.com
internal navigation rejected - <allow-navigation> not set for url='mailto:test#me.com'
All you need to is to add allow-navigation in your config.xml
So your config.xml will be:
<access origin="mailto:*" launch-external="yes"/>
<allow-intent href="mailto:*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-navigation href="mailto:*" />
I use this config in config.xml
for ios
<allow-navigation href="tel:*" />
for android
<allow-intent href="tel:*"/>
Altering Cordova's WhiteListPlugin in config.xml did not work for me -- <access >,`. I tried many combinations, including those above. Doesn't mean these won't work necessarily, just for my setup it doesn't. (Building for Browser, Android, and iOS)
However, using the Cordova InAppBrowser Plugin worked:
Use the inAppBrowser plugin and set the target to _system.
cordova.InAppBrowser.open('tel:123456789', '_system');
This by passes the issues I was seeing in iOS with unsupported url, and launches the native system's web browser (i.e., Does not rely on WhiteListPlugin to allow the URL call).
Hope this helps.
Cordova version 6.3.1.

phonegap oauthio plugin wont load

Im testing the phone gap oauthio plugin but cannot get it to work
followed the docs.
added the plugin with the command line
and also installed inappbrowser
also added this to my config.xml
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="com.phonegap.plugins.oauthio" />
the inappbrowser its loaded and working.
but the OAUTH is not.
i added some alert() here and there
but when i add an alert to display the content o OAUTH it won't happen
alert('device ready'); //to see if the device is ready, no problems here
alert(window.open); //to see if inbrowserapp is loaded, no problems here
alert(OAuth);// no message. looks like is not defined,also tried alert(OAuth.initialize) same luck
OAuth.initialize("VeQmyEu0QtzIOO9WjM1IlAU0ty4");
alert('postinit');
inside the plugin the definition says "OAuth" so the name is ok and my installed plugins are
oauthio-test % phonegap plugin list
[phonegap] com.phonegap.plugins.oauthio
[phonegap] org.apache.cordova.inappbrowser
i also delete the contents of "platform/ios" to prevent file caching
my access are these
<access origin="*" />
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
<access origin="*graph.facebook.com*" />
<access origin="*api.twitter.com*" />
<access origin="*github.com*" />
no luck so far.
it felts like when I debuged in IE6
EDIT:
Added the full code that shows that im inside an event 'ondeviceready'
$(document).on('deviceready', function() {
alert('device ready');//shows ok
alert(window.open); //shows ok
alert(OAuth.OAuth.initialize);//it dies here
OAuth.initialize("VeQmyEu0QtzIOO9WjM1IlAU0ty4");
alert('postinit');//this alert won't displayed
$('#fb-connect').on('click', function() {
$('#result').html("");
OAuth.popup("facebook", function(e,r) {
if (e)
$('#result').html('error: ' + e.message);
else
// the access_token is available via r.access_token
// but the http functions automagically wrap the jquery calls
r.get('/me').done(function(data) {
$('#result').html("facebook: Hello, " + data.name + " !");
});
});
});
in terminal you need to past this url and enter
"phonegap plugin add https://github.com/oauth-io/oauth-phonegap ".
and you can use android or iOS simulator to run the application.
ok. so looks like it's a phone gap bug.
If you add a plugin later you need to clean up your platform and plugins/*.json files
I followed this post and the plugins were builded and installed correctly
Phonegap 3.0 IOS plugins not found

Blackberry webworks background page not working

I am studying blackberry webworks. I have done one demo, where there is one page that run in background and is loaded on device startup. I have used blackberry rim:background to specify background, and has started interval in background page, but the page is not working. Please help me in getting out of this problem,
Here is my code in config.xml
<content src="index.html" >
<rim:background src="index.html" runOnStartup="true" charset="string" />
</content>
And HTML code
Insert title here
<script type="text/javascript" src="timer.js" />
<script>
function background()
{
self.setInterval(interval,"3000");
}
function interval()
{
i=i+10;
}
}
</script>
<body onload=" background()" >
</body>
</html>
Thanks in advance!
which phone/OS are you looking to target with this sample? The background element of the config.xml is a little bit different for a BB10 app, than it is for OS 5-7.
For BB OS 5-7 you would do this just like you have above
<content src="index.html"><rim:background src="listener.html" runOnStartup="true" /></content>
I would check-out the sample config.xml documents over here, and make sure everything is setup properly to start with.

Resources