Check if another app handles A URL scheme that your app handles - ios

I will to check if another iOS application installed on a device handles a URL scheme. I can easily do that with the canOpenURL(_:).
The catch is my app also implements the same URL scheme but I only want my application to handle calls to the URL if no other application on the device handles it.

As you might've noticed, Apple values its users' privacy with utmost priority. Similarly, it also values its developers. Your task at hand at hand requires accessing the code of another application — which (un)fortunately is not possible.

Related

What sections of Apple Health app are available via the x-apple-health:// URL scheme?

I want let users view the Weight section of Apple's Health app to allow them to see detailed data, etc. I manage to open the Health app via the URL scheme x-apple-health://, but I would like to send them directly to the right place, e.g. x-apple-health://HealthData/measurements/Weight. I have had no success after trying different paths that made some sense.
Anyone has a reference on this?
Apple has not documented the x-apple-health:// scheme for use by apps. Attempting to use it is like using SPI - even if you find something that works now, it is likely to break in a future version of iOS. You should file a Radar with Apple to request an API for this purpose.

How to open my iOS App with custom URL scheme in Swift 3?

I need to open my particular UIViewController when the following link is clicked on the Safari browser:
http://my.sampledomain.com/en/customer/account/resetpassword/?id=24&token=8fbf662617d14c10f4a11f716c1b2285
When this link is clicked on the browser, I need to open my application on a particular screen and retrieve the data from this url. For example:
id = 24
token = 8fbf662617d14c10f4a11f716c1b2285
...and pass it to that particular UIViewController.
How can i do that?
What you are describing is called Deep Linking. It's a very common app feature to implement — most apps have it — and conceptually, it seems like an easy thing to build. However, it's complicated to get right, and there are a lot of edge cases.
You basically need to accomplish two things:
If the app is installed: open the app and route users to the correct content inside it.
If the app is NOT installed: forward users to the App Store so they can download it. Ideally, also route users to the correct content inside the app after downloading (this is known as 'deferred deep linking').
While not required, you'll also probably want to track all of this activity so you can see what is working.
If the app is installed
Your existing custom URI scheme fits into this category. However, Apple has decided that custom URI schemes are not a good technology, and deprecated them with iOS 9 in favor of Universal Links.
Apple is right about this. Custom URI schemes have a number of problems, but these are the biggest:
There is no fallback if the app isn't installed. In fact, you get an error.
They often aren't recognized as links the user can click.
To work around these, it used to be possible to use a regular http:// link, and then insert a redirect on the destination page to forward the user to your custom URI scheme, thereby opening the app. If that redirect failed, you could then redirect users to the App Store instead, seamlessly. This is the part Apple broke in iOS 9 to drive adoption of Universal Links.
Universal Links are a better user experience, because they are http:// links by default and avoid nasty errors. However, they are hard to set up and still don't work everywhere.
To ensure your users end up inside the app when they have it installed, you need to support both Universal Links and a custom URI scheme, and even then there are a lot of edge cases like Facebook and Twitter which require special handling.
If the app is NOT installed
In this case, the user will end up on your http:// fallback URL. At this point, you have two options:
Immediately forward the user directly to the App Store.
Send the user to your mobile website (and then use something like a smart banner to give them the option of going to the App Store).
Most large brands prefer the second option. Smaller apps often go with the first approach, especially if they don't have a website.
To forward the user to the App Store, you can use a Javascript redirect like this:
<script type="text/javascript">
window.onload = function() {
window.location = "https://itunes.apple.com/app/id1121012049";
};
</script>
Until recently, it was possible to use a HTTP redirect for better speed, but Apple changed some behavior in Safari with iOS 10.3, so this no longer works as well.
Deferred deep linking
Unfortunately there's no native way to accomplish this last piece on either iOS or Android. To make this work, you need a remote server to close the loop. You can build this yourself, but you really shouldn't for a lot of reasons, not the least of which being you have more important things to do.
Bottom line
Deep linking is very complicated. Most apps today don't attempt to set it up by building an in-house system. Free hosted deep link services like Branch.io (full disclosure: they're so awesome I work with them) and Firebase Dynamic Links can handle all of this for you, and ensure you are always up to date with the latest standards and edge cases.
See here for a video overview an employee at Branch made of everything you need to know about this.

iOS / Uber integration: link_text and partner_deeplink not working in testing

I'm making an iOS (v8.3+) app which is a mapping app. The user can define a starting point and destination. They can then tap the Share button and choose "Open in Uber", which will launch the Uber app via a deeplink URL like this:
uber://?client_id=MY_CLIENT_ID&action=setPickup&link_text=Watch%20progress%20in%20my%20app&partner_deeplink=SOMEDEEPLINK%3A%2F%2F&pickup[latitude]=123.456&pickup[longitude]=123.456&pickup[nickname]=PICKUP&pickup[formatted_address]=123%20Elm%20St&dropoff[latitude]=123.456&dropoff[longitude]=123.456&dropoff[nickname]=DROPOFF&dropoff[formatted_address]=456%20Elm%20St
(This sample URL includes some obviously fake data, for the sake of simplicity.)
I've registered at Uber and have a valid client ID. This call (via openURL) works correctly: the Uber app launches with the starting point and destination already populated. This is ALL that I've done with Uber; there's no other calls being made at all.
The problem is that the special branding text does not appear within the Uber app during the trip (and of course the related partner_deeplink doesn't work either).
What do I need to do in order to get it to work? Do I need to "enable" this functionality somehow? My app has registered its own custom URL scheme that I use as the "partner_deeplink=SOMEDEEPLINK%3A%2F%2F" portion of the uber:// URL. I know this works because I can use my custom URL scheme in Safari and it successfully launches my app.
Thanks in advance for any insights!
You need to Request Full Access in the Uber Developer Dashboard to get activated for the Trip Branding feature. Please check out the documentation here.
As soon as you're activated, you can set defaults for the custom assets and the deeplink parameters you're referring to are essentially used to dynamically override these defaults.

Prevent iOS URL scheme hijack

I have an app that gets opened from another app via a URL scheme. The URL contains signup tokens. As any app can register the same URL scheme as my app, I am concerned a "fake" app can do a man-in-the-middle attack and capture the signup tokens.
My idea is to check that the URL scheme does not open another app when my app is first opened.
From a security perspective, if the URL scheme opens my app the first time, will it always open my app in the future?
How about using iOS 9 universal links?
Unlike custom URL schemes, universal links can’t be claimed by other apps, because they use standard HTTP or HTTPS links to your website.
https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html
This way the "dispatch table" is on your server, so no other app can hijack the signup URL. (URL dispatch is based on AppIDs)
It's a valid (and usually ignored) attack vector. It isn't strictly a man-in-the-middle attack as it won't forward the URL on to your app (it can't). It's almost worse as the attacking app would only really be able to crash and it would look like your app had...
Another app could be installed any time your app is in the background. Technically it's possible that an update is released and installed for an existing app while your app is running (it's hard to know if that happens). So, it isn't safe to only test when your app is first opened.

Iphone application for parental control over browsing

Here I am interested in developing an Iphone application which will check the outgoing URL form any browser,or at least from safari browser.
So how can I check user entered URL or user clicked URL. I want to perform some other actions depending on the URL clicked .
Is there any way to get the URL sending from the device or URL receiving to the device.??
what can be the best approach to develope parental control application to avoid child from browsing unwanted sites.
Thanks
This is not possible, app on iOS are sandboxed and can not just interact with other apps let alone change there behavior.
iOS already provides such functionality (Settings -> General -> Restrictions -> Websites). As stated before, third-party apps are sandboxed and may not access these system level functionality.

Resources