Cordova trying to dial telephone number - ios

I am trying to dial a phone number in iOS, however I only have the simulator and an iPod Touch to test on.
The code uses something along the lines of:
window.location.href = 'tel:01234567890';
Working fine with Android, but in iOS it dies with:
Failed to load webpage with error: The URL can't be shown
Now, I do realise this has been asked before, but the general consensus from some time ago was "It doesn't work, you'll need to use a plugin". There haven't been many questions on this for some time though, and what questions there are seem to suggest it works when doing it programmatically (as above with window.location.href). I have tried the iOS PhoneDialer and the newer version of the same plugin, but both have errors in XCode (ARC forbids explicit message send of 'release') - a bit of faffing and I can get this running, but then PhoneGap doesn't find the plugin - it really feels like I'm hitting a brick wall with this method, and I can't believe something as simple as this requires something so over the top.
I know you cannot auto-dial/auto-call a number for security reasons, but all I need to do is open the dialer with number pre-populated, which is surely no different to a mailto:info#example.com link opening your email client with the sender pre-populated?
So, my questions are:
Has this changed with a recent update to PhoneGap, iOS or XCode?
Or, is it a case that I cannot do this on an iPod or Simulator, and it will work fine on an iPhone?
How can I fix it? :)

You didn't specify which version of Cordova you are using so I'm going to assume version > 3.
Make sure that InAppBrowser, a plugin since version 3, is installed and then open the link by calling it through Javascript like this:
window.open('tel:12345678', '_system')
_system will open it with the systems own browser which in turn will open the call dialog, if you use it against http://maps.apple.com/ it will open in the maps app and similar for other apps which opens for special urls.
Remarks:
As described in the docs of the InAppBrowser plugin the window.open function won't be set automatically. You have to do it your self: window.open = cordova.InAppBrowser.open;. Instead you can directly use cordova.InAppBrowser.open('tel:12345678', '_system');
Make sure your number doesn't have any blankspaces in it (the +
prefix is okay). For example you could use a function like the following,
assuming num is a string.
Function:
function placeCall(num) {
if (window.cordova) {
cordova.InAppBrowser.open('tel:' + num.replace(/\s/g,''), '_system');
}
}

Below Code works perfectly fine for iphone:-
window.open('tel:123456', '_system');
Simulator doesn't support dialer. No need to waste time.

Make sure that the phone number in your href also doesn't have any formatting in it, as on iOS it causes the link not to work in a PhoneGap App. So for example, use tel:0390005555, and not tel:(03) 9000 5555.

I don't believe this is a Cordova issue. I know in native iOS you cannot bring up the dialer on the simulator or on an iPod touch. You will need to test this on an actual iPhone.

I know this is a late answer time.
Try by adding // to the url. Like this tel://xxxxxxxxx and see if it works.
Worked for me in IOS 8.4, iPhone 6, 6+ as of today.

Related

Firebase Dynamic Link URL for iOS Not Opening in a Browser

So, my team has been working on our Flutter app, trying to get a few of the deep links we created to open a website. And everything worked out fine...until we tried it on iOS devices. For iOS devices, the deep link behaves correctly only when typed out in the address bar, but when it's tapped on, be it in a TODO list, or through SMS messages, it takes you immediately to the installed app.
These behaviors, however, only occur for all URLs of the same host, for example:
https://foo.page.link/some-suffix
https://foo.page.link/baz/some-other-suffix
etc. you get the idea
Apparently, it's something to do with how iOS handle URL prefixes. This answer provides the best explanation and solutions I have found so far. However, these feel more like workarounds than solutions that would allow us to config our links like we did with Android. I'm asking here because the answer itself is almost two years old and there might already be simpler solutions out there.
These are the behaviors we defined for iOS and Android

PWA iOS getting the sms: tag to open iMessage

We are currently developing a PWA for a client of ours. Everything has been going well, but while testing on iPhone (iOS 12.2) we are having an issue with the tags that have sms:123-456-7890 in the href. You get the "Safari cannot open this page because of the sms: tag" (paraphrasing).
If you are browsing the site via Safari (not in the PWA mode), the anchor tag works fine and your iMessage opens up with the number in it. But when you're in the PWA mode and click the link, you get a version of the message I mentioned above.
From doing research, this appears to be some sort of bug in the iOS 12.2 release, though not officially mentioned.
I'm curious if anyone has had any luck with a work-around for this issue?
Thanks in advance.
Edit..to add some code for the anchor tag....
123-456-7890
I've tried many different variations of the sms (with no // or ;), always same outcome when clicking it as a PWA. With Android, everything works fine in PWA mode.
I did find a workaround by using JavaScript
Code Example:
<a href="#" onclick="openSMSMobile();" >
function openSMSMobile(e) {
window.open('sms:1234567890', '_self');
return false;
}
And in case anyone is wondering, if you'd like to add text to the message body, you can use,
window.open('sms:1234567890&body=textGoesHere', '_self');
For Android you'll need,
window.open('sms:1234567890&body=textGoesHere', '_self');

Ionic 2 Storage does not work on iOS

I am using #ionic/storage as it looked quite promising after reading about it in the V2 Docs.
I use Chrome on my Windows 10 laptop so things appeared to be working perfectly fine at first. However, when I tested it on iPad, or even Firefox on my laptop, I was surprised to find out it did not work.
I was able to resolve the issue on Firefox by removing the sqlite plugin (I thought I will add it when I am ready for native testing):
cordova plugin remove cordova-sqlite-storage --save
Sadly, storage still doesn't work on the iPad. I tested it on Safari and Chrome. I am unable to debug this given the lack of developer tools or console.
I am quite frustrated how Apple makes you dependent on using a Mac to develop on their devices.
How do I go about fixing and debugging this?
I first import storage in Ionic 2:
import { Storage } from '#ionic/storage';
Then to save the data, I do this:
this.storage.set(pk, JSON.stringify(reportObj));
Where pk is just a unique key, and reportObj is an object that I stringify before storing. Again, keep in mind this just doesn't work in iOS.
Thanks.
Update:
So I managed to run the app in Safari and found out that .set actually works and the data gets stored in WebSQL. However, the get does not seem to work and I wasn't able to get any useful errors in the console.
OK, so after a lot of trial and error, I found out that the problem is not really with Storage. There appears to be some other issue with my UI, where it doesn't seem to work on iOS.
I decided to answer the part about testing the app on iOS while in development if you are not a Mac user. The best way for this appears to be to use Ionic View. You can use this simply by typing:
ionic upload
Make sure you create your account. In your iPad or iPhone, you can then download Ionic View app from iTune, sign in, and the app will appear there.
As you upload your code, simply upload again and almost instantly the app would upload on the device as you click Sync.
Hope other Windows users benefit from this.

IBM Worklight 5 - iOS app shows white screen on second launch

I'm having a problem with a hybrid app for iOS which I have written using Worklight 5. The problem is that the application only runs properly the first time it is launched, and after being closed in multi-tasking and relaunched, the app will not open properly and instead displays a white screen. The only way to get the application to run again is to delete it from the device completely and then re-install it.
This behaviour is the same in the iPad simulator and on a physical iPad.
I don't have any code to provide as all of the Objective-C is generated by Worklight and all I have written is the HTML5, CSS3 and Javascript and I think that's unlikely to be affecting it. Has anybody else experienced this issue and if so is there a way to resolve this problem? Thanks.
Actually the behavior sounds to me much more inline with changing the name of the HTML file itself and in application-descriptor.xml's mainFile element. Have you touched these? If yes, then you also need to change the name of the application's folder.
Here's something to try:
Open cordova.js inside the Xcode project.
Replace: execXhr.open('HEAD', "/!gap_exec", true);
With execXhr.open('HEAD', "/!gap_exec?" + +new Date, true);.
It's from a fix that was applied to Cordova 2.4. It adds a timestamp to the query param to prevent caching.
No idea if that will help, it sounds vaguely familiar to an issue I ran into.

How to create a HTML link to a build.phonegap app?

I have run into several problems with iOS development through phonegap recently, and unusually people around here have been unable to discuss these issues and even together we have (for the first time I have ever seen) not had a single comment or answer for these topics...
See https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app and iOS broswer data -> Cache & Cookie for Phonegap App / Session?...
However, I have found "solutions" to get around these, but its by no means answers to the issues in question which are still outstanding... just simply doing it a completely different way.
However, despite loosing web-view in phonegap, in an attempt to get around https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app I now have some issue that are outstanding...
I need to be able to navigate back to my App from the web-system !!!
However, I have no idea how. I have read info on creating URL Schema, but I am not sure if this is even possible through build.phonegap at all... and it seems faily complicated. Does anybody know of a way for iOS safari to do one of two things
Either
Open the app that is running in the background
or
close the current browser tab and navigate back to the app in the background.
The closing tab idea would be good, but not essential
Look forward to everyone thoughts and opinions on this one...
Henry
You can create an url scheme for any application you make yourself.
See tutorial here
It's not as terribly complicated as one would think, and the required objective-c code is minimal.
Once you have done this, you can use your own url scheme to launch your phonegap application from safari with a hyperlink.
This would not close the tab (you could do this with javascript if you wanted to)
but does put safari in the background, and opens your phonegap app.
(whether it is already running in the background or not)
It is even possible to pass data to the app using your url scheme.
It is not currently possible using PhoneGap Build in 2.2 and previous. Potentially a feature top be released in newer versions of Cordova/Phonegap

Resources