Empty Mobile Number is Callable in iOS? - ios

When implementing call feature. Noticed that empty strings are returning true in call checking using canOpenURL
let mobile = ""
if let url = URL(string: "tel://\(mobile)"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
Above code works perfectly and instead of asking user confirmation for making call, an alert being displayed without any title or message from OS. Is it bug from apple?
Anybody has faced this issue before?
I'm using device without sim, that can be reason?

canOpenURL merely indicates whether there is an app on the device capable of handling the URL scheme (the tel: portion in this case).
It doesn't validate the URL in any way. Validation isn't possible since only the destination app knows what forms a valid URL (remember you can use this function with any app's URL scheme, not just well-known schemes like tel:).
Apple could perhaps handle the malformed URL more gracefully, but if there is a risk that the number is empty, you need to check for that condition on your side.

Related

How can you ignore a universal link if a certain condition is not met?

We currently support wildcarding for Universal Links. So my applinks looks like: applinks:*.company.com.
Let's say I want to only handle a link if it is https://company.com/?query1=abc
Let's say I instead tap on a link that is https://company.com/?query1=123
Since the condition is not met, I want to ignore this link and prevent my iOS App from responding to it. Is this possible?
I thought I'd just be able to return false in continue:restorationHandler but that does not prevent the iOS App from opening.
Returning false from application(_:continue:restorationHandler:) doesn't result in the URL being passed back to Safari (as you have discovered). The documentation states:
If you don't implement this method or if your implementation returns false, iOS tries to create a document for your app to open using a URL
So returning false just results in iOS trying to launch your app in a different way.
What you can do is call open(_:options:completionHandler:) and pass the URL you received. The URL will then be opened in Safari; iOS won't pass your app a universal link that your app opens itself because that could create an infinite loop.

UIApplication.shared.open(URL(string: "tel://\(varContact)")!) asking for Call/Cancel? [duplicate]

It appears that Apple have changed the behaviour when making a phone call via the URL Scheme. We currently use this code to initiate a phone call:
let url = NSURL(string: "tel://011111111111")
UIApplication.sharedApplication().openURL()
Prior to iOS 10.2, this immediately launched the dialler and placed the phone call. It appears that this has now changed, and the user receives a prompt to confirm to make the phone call. It appears tel:// is behaving more like telprompt://. This is despite the official Apple URL Scheme document (last updated 2015) mentioning that user interaction is not required if a tel:// URL is opened from a native app.
Does anyone know if (a) this is new, expected behaviour and/or (b) if there is another way around this to initiate a phone call, without prompting the user?
Unfortunately the version 10.3 to restricted the direct calls phone and facetime.
Check yourself:
https://developer.apple.com/library/content/releasenotes/General/RN-iOSSDK-10.3/
https://support.apple.com/en-gb/HT207617

Are URL Schemes on iOS case-sensitive?

The official Apple documentation doesn't seem to specify whether iOS URL schemes are case-sensitive or not.
Can I register myApp and still get opened for someone calling openURL: on MyApp://params?
They are not case-sensitive.
You can verify this by entering both sms:// and sMs:// into the URL box in Safari.
Also, it seems that third-party URL schemes in the Safari address bar now lead to a page not found error. This must be new in iOS 9.3.x, because it did not do this before. Entering the URL into another app (e.g. Notes) and then opening it still works.
Edit: the above hypothesis about iOS 9.3.x is actually a bit more nuanced...
They work if…
You are starting from a ​blank​ screen
A page is still loading when you request the custom URL scheme
They do NOT work if…
You are on a webpage that has fully loaded before you request the custom URL scheme
Go figure

Swift's openURL method does not place a phone call with an Asterix sign (iOS 8.4)

I'm trying to place a PhoneCall in a swift application.
It works pretty simple with regular phone numbers using the openURL
method. However, when I try to use a string that contains an asterix (for example, dial the number (****02), the method returns false.
I've tried using string literals with no help.
Is it possible to do so at all? Thanks!
var url:NSURL = NSURL(string: "tel://****02")!
UIApplication.sharedApplication().openURL(url)
Phone Links
... To prevent users from maliciously redirecting phone calls or
changing the behavior of a phone or account, the Phone app supports
most, but not all, of the special characters in the tel scheme.
Specifically, if a URL contains the * or # characters, the Phone app
does not attempt to dial the corresponding phone number. ...
I remember reading an answer from somebody that Apple doesn't allow you to dial numbers that contain "*" or "#". If I remember the thread correctly, the rationale was that those let you do things like log in to automated phone systems, and that should be under the user's control.

Is it possible to add PHG affiliate parameters to these new App Store launch URLs in iOS 7?

To launch app page in App Store app on iOS 7, this URL format is required:
#"itms-apps://itunes.apple.com/app/id%#"
Can you also append the affiliate ID and campaign token to this URL like this?
#"itms-apps://itunes.apple.com/app/id%#&at=%#&ct=%#"
Or does it have to be a plain
#"https://itunes.apple.com/app/%#/id%#?mt=8&uo=4"
type URL like you do in websites? Disadvantage of this URL is it opens Safari and causes redirects.
Try it and see; the link will either open or it won't, and if it does, and if you specify a custom campaign for testing, it will either show up in PHG or it won't. Let us know what happens, as I'm curious myself.
Oh, and if it doesn't, please file a bug, as that seems like a useful feature, and it should be trivial for Apple to add it if they haven't already.

Resources