Custom URL Scheme Parameters - ios

When defining the custom URL scheme for my app there are 3 keys that I need information about:
CFBundleTypeRole a.k.a Document Role
CFBundleURLName a.k.a URL identifier
CFBundleURLSchemes a.k.a. URL Schemes
I can see, if I just define CFBundleURLSchemes to be myapp the app is launching fine with an URL as myapp://.
Questions are:
Is the URL identifier there only to make my scheme unique? How does
it do that? If I have same scheme myapp defined in 2 apps, and I call myapp://
can I specify which one I want to call by calling myapp://<URL Identifier>?
Edit: What does this URL Identifier actually do? Does it only give a name to url? How it is used?
The Role defines the level of permission which is
None, Viewer or Editor, I am not sure what level of permission my
app has on the launched app as I have not defined anything. I would
like to know what is the default permission when the
CFBundleTypeRole is not defined.

to 1:
A protocol is not guaranteed to be unique. There is no parameter you can define that will open app1 or app2. If two apps use the same scheme it is undefined what happens
to 2:
the role is irrelevant for the most part BUT mandatory:
editor = launched because they can R/W files identified by the same
viewer = can only read and display

Ad 1)
According to Apple documentation they don't give much info about the identifier and why it is needed or where it is used. They only say that it should be unique.
Also if more than one app specify the same url scheme, then the outcome is unpredictable.
See URL identifier and URL scheme
Ad 2)
The Role flag isn't used by iOS.
See In Xcode, under Info tab, what's Role for in URL Types section?

Related

how to open dynamic URL scheme in Swift

I want to make an app that opens URL schemes that entered by user.
I found it is necessary to add the URL scheme in info.plist and info.plist isn't changed dynamically.
But I saw some app that have this function.
I need to open URL schemes that managed by users(add/update/delete), what should I do?
Please help me T.T
The domain itself should be in info.plist, but what you can handle inside the code is after the domain. For example: yourdomain.com/add or yourdomain.com/update.
Then inside your code when you handle the URL scheme you can check for the string after your domain.

Record mywebsite.com link with query in LSApplicationQueriesSchemes

My iOS 11.0+ app is trying to open a URL of the following format, where DATANAME1, DATANAME2, USERNAME vary depending upon the user looking at different data:
http://www.mywebsite.com/Topic.html?topic=DATANAME1-USERNAME-DATANAME2
However, the command 'canOpenURL' I use before calling this link returns false. I believe this is due to not having whitelisted this link.
Consider that any html page within mywebiste.com (for example: http://www.mywebsite.com/Help.html) can instead be opened without any issue.
Questions:
Since I cannot whitelist every possible combination of USERNAME, DATANAME1, DATANAME2 obviously, is there a way to whitelist the link under the key LSApplicationQueriesSchemes in info.plist?
Do I need to add a URLScheme (under Info->URL Types) as well? What would be the right string to add in this case?
Thanks.

How to add url deeplink in iOS Swift

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

Multiple URL Schemes in iOS

I'm trying to add URL schemes to my iOS app such that multiple URL schemes can target my app, but they will all be under the same identifier. To my understanding, I can only have one URL scheme for the identifier. . But I want the app to respond to multiple similar URL Schemes. So it would also respond to a scheme like this. . The only way I know how is to manually add each URL scheme as follows: . Does anyone know of a solution that allows all URLs of a certain pattern?
There is no technical reason to have all your urls have the same Identifier. Apple recommends you use reversed DNS style names to ensure uniqueness. I usually use <bundle ID here>.schema_name
Identifier Scheme
---------- ------
com.mycompany.myapp.schema1 schema1
com.mycompany.myapp.schema2 schema2
Edit Info.plist to add URL Types -> Item -> URL Schemes's String values.
You can separate them by comma.

Why do we need "URL Identifier" (CFBundleURLName) plist field to use custom URL scheme on iOS?

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

Resources