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