How can I add deeplink (url like https://www.example.com) in iOS using swift.
The scheme in plist is not working if I enter url in it.
You can check the screenshot of plist attached.
You are attempting to register your app for the URI scheme https which Apple has already reserved for Safari, therefore you will not be able to use it.
Option 1: Custom URI Scheme
You must come up with a custom URI scheme like customURI://www.domain.com
Downside: If a user clicks on this link without the app installed. iOS will show that user and error.
Option 2:Universal Links
Apple launched Universal Links in iOS 9 to enable developers to associate their http link with their app. This requires you to host your own AASA file on your domain so that your domain becomes associated with your app ID.
Option 3: Branch.io
Branch will actually bundle up Universal Links and URI schemes and use them appropriately when necessary. They also perform deferred deep linking. They'll host your AASA file for you, but your app domain will have to be either https://*.app.link or some dedicated subdomain of a domain that you own.
only to be precise:
If you need more docs about in Apple docs, use the CORRECT name for the technology.
If You use url starting with a schema different from http (for example fb:// for FB) is not a LINK, is a "custom" url.
Anyway use: custom url and see at:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
Related
Any ideea how is this getting true in
appUrl = "http://dum:site2015#jobz.store.com/
if UIApplication.shared.canOpenURL(appUrl!){
if #available(iOS 10.0, *) {
UIApplication.shared.open(appUrl!)
}
and in url scheme i have jobz-com
the thing is it getting true althought I don't have the app installed ...instead is opening the url in safari... but why is not getting false since i don't have the app installed?
This function does not check for apps installed. It just tells you if it can open that URL, in safari or through an app.
A valid URL will always return true because the system can actually open it somewhere.
According to Apple's own documentation
A URL (Universal Resource Locator). At runtime, the system tests the URL’s scheme to determine if there is an installed app that is registered to handle the scheme. More than one app can be registered to handle a scheme.
https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl
Safari is registered to handle any valid URL, so if the app using the scheme does not exist, the next application registered to read it is safari.
I don't think there's an open API for you to only open an URL if the app is installed.
And always make sure that your URL starts with the scheme you need and not HTTP/S.
my-app://myurl/parameters
Do not use http:// or https:// to open apps. These are for websites. Use app url schemes like this:
jobz-com://
Edit
Another way of doing what the questioner is trying to achieve is to use Universal Link.
Here is the Apple's Official doc about Universal Links and you can follow this medium article which says:
The workaround approach to deep linking with URI schemes involves
using a traditional http:// link to launch a web browser. This link
contains a JavaScript redirect to a custom URI scheme, which is
executed by the web browser to launch the app. If the redirect attempt
fails because the app is not installed, the JavaScript then takes the
user to the App Store or Play Store.
Instead of opening up
Safari first when a link is clicked, iOS will check if a Universal
Link has been registered (an AASA (apple-app-site-association) file
should be there in the domain which contains the bundle id of the app
and the paths the app should open) for the domain associated with the
link, then check if the corresponding app is installed. If the app is
currently installed, it will be opened. If it’s not, Safari will open
and the http(s) link will load.
I've found two options to open my app from a Safari web page: a custom URL scheme created in my app project's Info.plist or Apple's Universal Linking. Obviously the custom URL scheme is the easiest one to set up, but the problem I'm having with this is that Safari shows a confirmation window asking "Open myapp?" first and the user has to tap OK before the app actually opens. I want my app to open automatically as the scheme is opened, and I'm being told the only way to do this is through Universal Linking (please correct me if this is not true). If this is true, however, I would like to know if it's possible in any way to put the required apple-app-site-association file on a http:// domain instead of https://? According the official Apple documentation the format of a correct Universal Link starts explicitly with https:// but my domain name can't be loaded on https:// without redirecting a few times and that messes up the web services I've written to execute other tasks in my app. The two main questions I'm left with after this issue:
1) Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
2) If I have to use Apple Universal Linking, can I use a http:// domain? If so, how do I do it? Right now if I load up the universal link, it just shows the dictionary inside the apple-app-site-association file, which I'm pretty sure is not supposed to happen. I'm told it's supposed to send a NSUserActivity object to my app delegate. How can I accomplish this with a http:// link?
It is not possible to trigger a custom URI scheme without showing an alert to the user. This used to be possible in iOS 8, but iOS 9 started showing the alert for all apps. And iOS 10.3 has extended that even to the App Store itself. You cannot bypass this. Universal Links were created to replace URI schemes for this behavior, so you do need to use them instead.
From your description, I believe you may be misunderstanding how Universal Links work. To answer the literal questions you asked first, no the Universal Link URL itself does not need to be on the https:// protocol, and yes, the apple-app-site-association must be served over https:// without redirects.
However, it sounds like you're trying to serve the content of the apple-app-site-association file for every Universal Link. That is not the correct implementation — the AASA file is hosted only at https://example.com/apple-app-site-association, and iOS automatically retrieves it when the app is installed. After that, any URL on example.com that matches the criteria in the AASA file will be eligible for Universal Links.
All of that said, you really don't want to built out this system on your own. I suggest looking into Firebase Dynamic Links or Branch.io (full disclosure: I'm on the Branch team).
Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
That is possible with some hacky tricks and BAD user experience. It requires user to press "add to home screen" button, so I don't recommend this solution in most cases.
set your app scheme like myapp
create the following html file and put it into the web
window.onload = function() {
if (("standalone" in window.navigator) && window.navigator.standalone) {
window.location.href = 'myapp://open'
}
}
open the html file with safari and "add to home screen"
open the home screen icon and your native app will launch
The point is the meta tag.
<meta name="apple-mobile-web-app-capable" content="yes" />
Without this, safari will launch and confirmation prompt will appear.
How to Open an iOS App using Firebase Dynamic Links and Pass or get Parameters To an App Via Custom URL Scheme in iOS(swift)?
for eg :- https://q3tyj.app.goo.gl/abcd
My URL Scheme is ‘q3tyj.app.goo.gl’ in iOS app in Url Types.
If I type q3tyj.app.goo.gl in safari, I am able to open the application. But if I type q3tyj.app.goo.gl with some extra parameter like https://q3tyj.app.goo.gl/abcd in safari, , I am not able to open the application.
please also explain me how to get “link” parameter (which associated with dynamic link) from dynamic link in iOS app ( Swift ) .
I followed steps which were mentioned in Firebase.google.com for iOS ( Swift ).but its not working.
Thanks,
Nirav Virpara
It's hard to know exactly where your error is, but a few things to help you debug:
If you go to https://q3tyj.app.goo.gl/apple-app-site-association, you should see some JSON that points to your app. If you don't see this, make sure you've entered your team ID and your App Store ID in the project settings in the Firebase console
Make sure you're using your Bundle ID, not the shortlink domain, as your custom URL scheme in Xcode
Make sure you've enabled Associated Domains in the Capabilities tab of your Xcode project, and your domain looks like applinks:q3tyj.app.goo.gl
Universal Links (and, therefore, Dynamic Links) generally don't work if you type them directly into the Safari address bar. Instead, try typing the URL into an app like Notes and then clicking on them from there.
Good luck!
If you type https://q3tyj.app.goo.gl/apple-app-site-association this link in your browser and check, you will end up seeing a json, meaning your apple-app-site-association is correctly configured on your google website. However, you need to make sure that teamid in your google console or appid is correct.
I successfully have a message url from the gmail api:
https://mail.google.com/mail/?authuser=roy#companyemail.co#all/155134b5e66a9b06
However, when i call the [[UIApplication sharedApplication] openURL:url] method, the web client gets opened up instead of the native iOS application (and just shows the inbox, not the specific message). Not sure if it has to do with the LSApplicationQueriesSchemes or not, but regardless - couldn't find any documentation on this in the Gmail iOS documentation, so if anyone has any ideas!
Thanks
Through the links the Brett posted, this deep link url allowed me to open gmail:
googlegmail://
Still searching for instructions on deep linking to a specific email though
It seems that the openURL method is designed to do what you want to do. But any URL which starts with http: or https: is going to open in Safari. Here is a quote from the doco.
A URL (Universal Resource Locator). UIKit supports many common
schemes, including the http, https, tel, facetime, and mailto schemes.
You can also employ custom URL schemes associated with apps installed
on the device.
I presume that if you wanted to compose a message in the built-in Mail app, you would use a mailto: URL. Not sure about opening an existing message. And if you want to open an existing message in another app, then that app would need to define a custom URL scheme, and you'd need to use that.
I am using a custom URL scheme to open my iOS app when this web link is tapped on the device: Demo77://someurl
To set it up, I added Demo77 as an item to the URL Schemes (CFBundleURLSchemes) array in the Info.plist.
Apple documentation says I also need to include URL identifier (CFBundleURLName) string key into the Info.plist. This key contains the "abstract name of the URL scheme".
I did not include the URL identifier key and the links still open my app. Everything works without the URL identifier.
Question: do I really need to include the URL identifier key in the plist? And if so - why?
Update
This question is different from URL identifier and URL scheme where it is asked what "URL Identifier" key is used for. I am not asking what it is used for. I am asking if we need to use "URL Identifier" at all? URL schemes in my app work perfectly well without it. Note that answers to the URL identifier and URL scheme question do not address my question at all. Sorry if my initial question was not clear enough.
According to apple docs
The identifier you supply with your scheme distinguishes your app from others that declare support for the same scheme.
Although using a reverse DNS string is a best practice, it does not prevent other apps from registering the same scheme and handling the associated links. Use universal links instead of custom URL schemes to define links that are uniquely associated with your website.
So to answer your question adding a url identifier doesn't change much,but its best to include it,as it is specified by apple.
If you have 2 application installed with same URL scheme like:
yourscheme://
then you have 2 conflicting apps.
How will the system decide to open which application launch?
According to the Inter-App Communication documentation
If more than one third-party app registers to handle the same URL
scheme, there is currently no process for determining which app will
be given that scheme
Please check this answer for the user who experienced the issue:
Also as far as I've tested and experienced, if you have 2 conflicting
apps, it appears to be the first one installed which is used, and when
this app is removed the second app which is now the only app
supporting the specific URL scheme is still not used
Hope it helps.
The URL Identifier is the reversed domain address which is should be the same as your Bundle Identifier e.g. com.companyname.appname
The URL Schemes is the start of the URL e.g 'appname'. When you call this as a URL it targets the bundle identifier which launches the app.
Reference : URL Identifier and URL Schemes