From 495a2ad6d8d7bfed073ea7cef05101d8e82dc317 Mon Sep 17 00:00:00 2001 From: Ryan Wilson Date: Tue, 27 Nov 2018 14:31:56 -0500 Subject: [PATCH] Avoid using default FIROptions directly. Instead of using [FIROptions defaultOptions] we should be using FIRApp's options. This will allow developers to use custom FIROptions instead of the default named info.plist. --- .../FIRDynamicLinkComponentsKeyProvider.h | 6 +----- .../FIRDynamicLinkComponentsKeyProvider.m | 21 +++++++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h b/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h index a5f5453c241..a6e11dd9223 100644 --- a/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h +++ b/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h @@ -16,12 +16,8 @@ #import -NS_ASSUME_NONNULL_BEGIN - @interface FIRDynamicLinkComponentsKeyProvider : NSObject -+ (NSString *)APIKey; ++ (nullable NSString *)APIKey; @end - -NS_ASSUME_NONNULL_END diff --git a/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.m b/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.m index 10c8af603ae..0d4625f9f7f 100644 --- a/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.m +++ b/Firebase/DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.m @@ -16,21 +16,20 @@ #import "DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h" +#import #import -NS_ASSUME_NONNULL_BEGIN - @implementation FIRDynamicLinkComponentsKeyProvider -+ (NSString *)APIKey { - static NSString *apiKey; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - apiKey = [FIROptions defaultOptions].APIKey; - }); - return apiKey; ++ (nullable NSString *)APIKey { + // If there's no default app, immediately return nil since reading from the default app will cause + // an error to be logged. + if (![FIRApp isDefaultAppConfigured]) { + return nil; + } + + // FDL only supports the default app, use the options from it. + return [FIRApp defaultApp].options.APIKey; } @end - -NS_ASSUME_NONNULL_END