diff options
author | Xiangtian Dai <xiangtian@google.com> | 2017-10-19 08:58:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-19 08:58:36 -0700 |
commit | a9585971c35799b06501fe5bba1cf584d000d27b (patch) | |
tree | c9baa39d180d72ee1095b638d0cab0ca8550b290 /Firebase/Auth/Source/FIRAuthAppDelegateProxy.m | |
parent | 024788e38a5e506cf4861aa66afda2bc3b9115e1 (diff) |
Silences unguarded availability warnings in Auth. (#389)
Also fixes a crash in the Auth sample app in an error case.
This addresses *Auth* part of #385 .
Diffstat (limited to 'Firebase/Auth/Source/FIRAuthAppDelegateProxy.m')
-rw-r--r-- | Firebase/Auth/Source/FIRAuthAppDelegateProxy.m | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m index 8899407..8b8e1bb 100644 --- a/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m +++ b/Firebase/Auth/Source/FIRAuthAppDelegateProxy.m @@ -40,6 +40,21 @@ static id noop(id object, SEL cmd, ...) { } #endif +/** @fn isIOS9orLater + @brief Checks whether the iOS version is 9 or later. + @returns Whether the iOS version is 9 or later. + */ +static BOOL isIOS9orLater() { +#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0) + if (@available(iOS 9.0, *)) { + return YES; + } + return NO; +#else + return &UIApplicationOpenURLOptionsAnnotationKey; // the constant is only available on iOS 9+ +#endif +} + @implementation FIRAuthAppDelegateProxy { /** @var _appDelegate @brief The application delegate whose method is being swizzled. @@ -119,7 +134,7 @@ static id noop(id object, SEL cmd, ...) { SEL openURLOptionsSelector = @selector(application:openURL:options:); SEL openURLAnnotationSelector = @selector(application:openURL:sourceApplication:annotation:); SEL handleOpenURLSelector = @selector(application:handleOpenURL:); - if (&UIApplicationOpenURLOptionsAnnotationKey && // the constant is only available on iOS 9+ + if (isIOS9orLater() && ([_appDelegate respondsToSelector:openURLOptionsSelector] || (![_appDelegate respondsToSelector:openURLAnnotationSelector] && ![_appDelegate respondsToSelector:handleOpenURLSelector]))) { |