UIApplicationOpenURLOptionUniversalLinksOnly causes crash on iOS9 even though it's enclosed in an @available condition

287 Views Asked by At

I'm trying to support iOS9 in an app that uses Microsoft Sign In and found that the app crashes because it cannot find the definition for UIApplicationOpenURLOptionUniversalLinksOnly even though in the MSAL code this is enclosed in an @available condition. The app doesn't even reach that point in the code, it crashes at the start.

This is the code where the symbol is found (MSIDBrokerInteractiveController.m):

- (void)openBrokerWithRequestURL:(NSURL *)requestURL
       fallbackToLocalController:(BOOL)shouldFallbackToLocalController
{
    NSDictionary *options = nil;

    if (self.interactiveParameters.brokerInvocationOptions.isUniversalLink)
    {
        // Option for openURL:options:CompletionHandler: only open URL if it is a valid universal link with an application configured to open it
        // If there is no application configured, or the user disabled using it to open the link, completion handler called with NO
        if (@available(iOS 10.0, *))
        {
            options = @{UIApplicationOpenURLOptionUniversalLinksOnly : @YES};
        }
    }

    [MSIDAppExtensionUtil sharedApplicationOpenURL:requestURL
                                           options:options
                                 completionHandler:^(BOOL success) {

                                     if (!success)
                                     {
                                         MSID_LOG_WITH_CTX(MSIDLogLevelWarning, self.requestParameters, @"Failed to open broker URL. Falling back to local controller");

                                         [self handleFailedOpenURL:shouldFallbackToLocalController];
                                     }
    }];
}

My solution has been to either comment the line or just substitute the constant with its string value @"UIApplicationOpenURLOptionUniversalLinksOnly" (leaving the @available condition, so it should never run on iOS9). Anyway, both solutions seem to work fine in any OS but I'm not sure if they can cause a problem in the future... Any thought would be appreciated.

0

There are 0 best solutions below