Forum Xamarin.iOS

OpenUrl on iOS version below 10.0

descorpdescorp RUUniversity ✭✭


There are three overload for UIApplication.SharedApplication.OpenUrl :

bool OpenUrl (NSUrl url) - marked as deprecated
void OpenUrl (NSUrl url, NSDictionary options, [BlockProxy (typeof(Trampolines.NIDActionArity1V2))] Action completion)
void OpenUrl (NSUrl url, UIApplicationOpenUrlOptions options, [BlockProxy (typeof(Trampolines.NIDActionArity1V2))] Action completion)

Compiler warns you that this API requires IOS 10.0 or later for all three of them.

Is it bug or feature ?



  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai


    I wouldn't call it either a bug or a feature, it is the API as handed down by apple. See Apple's docs:

    API docs for UIApplication:

    The info for the openUrl method:

    func open​URL(URL) - Attempts to open the resource at the specified URL. - Deprecated

    In the docs for the above method,, it says:

    Deprecated - Use the open(_:​options:​completion​Handler:​) method instead.

    And looking at the docs for the open(_:​options:​completion​Handler:​) method,, it seems this was added in iOS 10:

    iOS 10.0+
    tvOS 10.0+

    And even though Apple is calling the method open we are still mapping it to the OpenUrl method in Xamarin.iOS. The last two overloads in Xamarin.iOS are because you have 2 options to provide the options argument, either an NSDictionary or a UIApplicationOpenUrlOptions, to which it seems you can supply an NSDictionary to set the options. I would say the second overload seems redundant but I have to assume there is a reason it was provided. \

    That said the messages you are getting are correct according to Apple's docs. The first overload is indeed deprecated and the 2nd and 3rd were indeed added in iOS 10, so if you need to support < iOS 10 you will have to do an iOS version check and run the 1st overload on iOS < 10 and run the 2nd (or 3rd) overload when running on iOS 10.

Sign In or Register to comment.