Archived
Push from command line
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "Private/FIRAnalyticsConfiguration.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
|
||||
@implementation FIRAnalyticsConfiguration
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
+ (FIRAnalyticsConfiguration *)sharedInstance {
|
||||
static FIRAnalyticsConfiguration *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[FIRAnalyticsConfiguration alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)postNotificationName:(NSString *)name value:(id)value {
|
||||
if (!name.length || !value) {
|
||||
return;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:name
|
||||
object:self
|
||||
userInfo:@{name : value}];
|
||||
}
|
||||
|
||||
- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled {
|
||||
[self setAnalyticsCollectionEnabled:analyticsCollectionEnabled persistSetting:YES];
|
||||
}
|
||||
|
||||
- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled
|
||||
persistSetting:(BOOL)shouldPersist {
|
||||
// Persist the measurementEnabledState. Use FIRAnalyticsEnabledState values instead of YES/NO.
|
||||
FIRAnalyticsEnabledState analyticsEnabledState =
|
||||
analyticsCollectionEnabled ? kFIRAnalyticsEnabledStateSetYes : kFIRAnalyticsEnabledStateSetNo;
|
||||
if (shouldPersist) {
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
[userDefaults setObject:@(analyticsEnabledState)
|
||||
forKey:kFIRAPersistedConfigMeasurementEnabledStateKey];
|
||||
[userDefaults synchronize];
|
||||
}
|
||||
|
||||
[self postNotificationName:kFIRAnalyticsConfigurationSetEnabledNotification
|
||||
value:@(analyticsCollectionEnabled)];
|
||||
}
|
||||
|
||||
@end
|
||||
Generated
+836
@@ -0,0 +1,836 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#if __has_include(<UIKit/UIKit.h>)
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
#if __has_include(<AppKit/AppKit.h>)
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
#import "FIRApp.h"
|
||||
|
||||
#import "Private/FIRAnalyticsConfiguration.h"
|
||||
#import "Private/FIRAppInternal.h"
|
||||
#import "Private/FIRBundleUtil.h"
|
||||
#import "Private/FIRComponentContainerInternal.h"
|
||||
#import "Private/FIRConfigurationInternal.h"
|
||||
#import "Private/FIRCoreDiagnosticsConnector.h"
|
||||
#import "Private/FIRLibrary.h"
|
||||
#import "Private/FIRLogger.h"
|
||||
#import "Private/FIROptionsInternal.h"
|
||||
|
||||
// The kFIRService strings are only here while transitioning CoreDiagnostics from the Analytics
|
||||
// pod to a Core dependency. These symbols are not used and should be deleted after the transition.
|
||||
NSString *const kFIRServiceAdMob;
|
||||
NSString *const kFIRServiceAuth;
|
||||
NSString *const kFIRServiceAuthUI;
|
||||
NSString *const kFIRServiceCrash;
|
||||
NSString *const kFIRServiceDatabase;
|
||||
NSString *const kFIRServiceDynamicLinks;
|
||||
NSString *const kFIRServiceFirestore;
|
||||
NSString *const kFIRServiceFunctions;
|
||||
NSString *const kFIRServiceInstanceID;
|
||||
NSString *const kFIRServiceInvites;
|
||||
NSString *const kFIRServiceMessaging;
|
||||
NSString *const kFIRServiceMeasurement;
|
||||
NSString *const kFIRServicePerformance;
|
||||
NSString *const kFIRServiceRemoteConfig;
|
||||
NSString *const kFIRServiceStorage;
|
||||
NSString *const kGGLServiceAnalytics;
|
||||
NSString *const kGGLServiceSignIn;
|
||||
|
||||
NSString *const kFIRDefaultAppName = @"__FIRAPP_DEFAULT";
|
||||
NSString *const kFIRAppReadyToConfigureSDKNotification = @"FIRAppReadyToConfigureSDKNotification";
|
||||
NSString *const kFIRAppDeleteNotification = @"FIRAppDeleteNotification";
|
||||
NSString *const kFIRAppIsDefaultAppKey = @"FIRAppIsDefaultAppKey";
|
||||
NSString *const kFIRAppNameKey = @"FIRAppNameKey";
|
||||
NSString *const kFIRGoogleAppIDKey = @"FIRGoogleAppIDKey";
|
||||
|
||||
NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat =
|
||||
@"/google/firebase/global_data_collection_enabled:%@";
|
||||
NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey =
|
||||
@"FirebaseDataCollectionDefaultEnabled";
|
||||
|
||||
NSString *const kFIRAppDiagnosticsNotification = @"FIRAppDiagnosticsNotification";
|
||||
|
||||
NSString *const kFIRAppDiagnosticsConfigurationTypeKey = @"ConfigType";
|
||||
NSString *const kFIRAppDiagnosticsErrorKey = @"Error";
|
||||
NSString *const kFIRAppDiagnosticsFIRAppKey = @"FIRApp";
|
||||
NSString *const kFIRAppDiagnosticsSDKNameKey = @"SDKName";
|
||||
NSString *const kFIRAppDiagnosticsSDKVersionKey = @"SDKVersion";
|
||||
|
||||
// Auth internal notification notification and key.
|
||||
NSString *const FIRAuthStateDidChangeInternalNotification =
|
||||
@"FIRAuthStateDidChangeInternalNotification";
|
||||
NSString *const FIRAuthStateDidChangeInternalNotificationAppKey =
|
||||
@"FIRAuthStateDidChangeInternalNotificationAppKey";
|
||||
NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey =
|
||||
@"FIRAuthStateDidChangeInternalNotificationTokenKey";
|
||||
NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey =
|
||||
@"FIRAuthStateDidChangeInternalNotificationUIDKey";
|
||||
|
||||
/**
|
||||
* The URL to download plist files.
|
||||
*/
|
||||
static NSString *const kPlistURL = @"https://console.firebase.google.com/";
|
||||
|
||||
/**
|
||||
* An array of all classes that registered as `FIRCoreConfigurable` in order to receive lifecycle
|
||||
* events from Core.
|
||||
*/
|
||||
static NSMutableArray<Class<FIRLibrary>> *sRegisteredAsConfigurable;
|
||||
|
||||
@interface FIRApp ()
|
||||
|
||||
#ifdef DEBUG
|
||||
@property(nonatomic) BOOL alreadyOutputDataCollectionFlag;
|
||||
#endif // DEBUG
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRApp
|
||||
|
||||
// This is necessary since our custom getter prevents `_options` from being created.
|
||||
@synthesize options = _options;
|
||||
|
||||
static NSMutableDictionary *sAllApps;
|
||||
static FIRApp *sDefaultApp;
|
||||
static NSMutableDictionary *sLibraryVersions;
|
||||
|
||||
+ (void)configure {
|
||||
FIROptions *options = [FIROptions defaultOptions];
|
||||
if (!options) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find "
|
||||
@"a valid GoogleService-Info.plist in your project. Please download one "
|
||||
@"from %@.",
|
||||
kPlistURL];
|
||||
}
|
||||
[FIRApp configureWithOptions:options];
|
||||
#if TARGET_OS_OSX || TARGET_OS_TV
|
||||
FIRLogNotice(kFIRLoggerCore, @"I-COR000028",
|
||||
@"tvOS and macOS SDK support is not part of the official Firebase product. "
|
||||
@"Instead they are community supported. Details at "
|
||||
@"https://github.com/firebase/firebase-ios-sdk/blob/master/README.md.");
|
||||
#endif
|
||||
}
|
||||
|
||||
+ (void)configureWithOptions:(FIROptions *)options {
|
||||
if (!options) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"Options is nil. Please pass a valid options."];
|
||||
}
|
||||
[FIRApp configureWithName:kFIRDefaultAppName options:options];
|
||||
}
|
||||
|
||||
+ (NSCharacterSet *)applicationNameAllowedCharacters {
|
||||
static NSCharacterSet *applicationNameAllowedCharacters;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
NSMutableCharacterSet *allowedNameCharacters = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[allowedNameCharacters addCharactersInString:@"-_"];
|
||||
applicationNameAllowedCharacters = [allowedNameCharacters copy];
|
||||
});
|
||||
return applicationNameAllowedCharacters;
|
||||
}
|
||||
|
||||
+ (void)configureWithName:(NSString *)name options:(FIROptions *)options {
|
||||
if (!name || !options) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain format:@"Neither name nor options can be nil."];
|
||||
}
|
||||
if (name.length == 0) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain format:@"Name cannot be empty."];
|
||||
}
|
||||
|
||||
if ([name isEqualToString:kFIRDefaultAppName]) {
|
||||
if (sDefaultApp) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"Default app has already been configured."];
|
||||
}
|
||||
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000001", @"Configuring the default app.");
|
||||
} else {
|
||||
// Validate the app name and ensure it hasn't been configured already.
|
||||
NSCharacterSet *nameCharacters = [NSCharacterSet characterSetWithCharactersInString:name];
|
||||
|
||||
if (![[self applicationNameAllowedCharacters] isSupersetOfSet:nameCharacters]) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"App name can only contain alphanumeric, "
|
||||
@"hyphen (-), and underscore (_) characters"];
|
||||
}
|
||||
|
||||
@synchronized(self) {
|
||||
if (sAllApps && sAllApps[name]) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"App named %@ has already been configured.", name];
|
||||
}
|
||||
}
|
||||
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000002", @"Configuring app named %@", name);
|
||||
}
|
||||
|
||||
@synchronized(self) {
|
||||
FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options];
|
||||
if (app.isDefaultApp) {
|
||||
sDefaultApp = app;
|
||||
}
|
||||
|
||||
[FIRApp addAppToAppDictionary:app];
|
||||
[FIRApp sendNotificationsToSDKs:app];
|
||||
}
|
||||
}
|
||||
|
||||
+ (FIRApp *)defaultApp {
|
||||
if (sDefaultApp) {
|
||||
return sDefaultApp;
|
||||
}
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000003",
|
||||
@"The default Firebase app has not yet been "
|
||||
@"configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your "
|
||||
@"application initialization. Read more: https://goo.gl/ctyzm8.");
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (FIRApp *)appNamed:(NSString *)name {
|
||||
@synchronized(self) {
|
||||
if (sAllApps) {
|
||||
FIRApp *app = sAllApps[name];
|
||||
if (app) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000004", @"App with name %@ does not exist.", name);
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSDictionary *)allApps {
|
||||
@synchronized(self) {
|
||||
if (!sAllApps) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000005", @"No app has been configured yet.");
|
||||
}
|
||||
return [sAllApps copy];
|
||||
}
|
||||
}
|
||||
|
||||
// Public only for tests
|
||||
+ (void)resetApps {
|
||||
@synchronized(self) {
|
||||
sDefaultApp = nil;
|
||||
[sAllApps removeAllObjects];
|
||||
sAllApps = nil;
|
||||
[sLibraryVersions removeAllObjects];
|
||||
sLibraryVersions = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteApp:(FIRAppVoidBoolCallback)completion {
|
||||
@synchronized([self class]) {
|
||||
if (sAllApps && sAllApps[self.name]) {
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000006", @"Deleting app named %@", self.name);
|
||||
|
||||
// Remove all cached instances from the container before deleting the app.
|
||||
[self.container removeAllCachedInstances];
|
||||
|
||||
[sAllApps removeObjectForKey:self.name];
|
||||
[self clearDataCollectionSwitchFromUserDefaults];
|
||||
if ([self.name isEqualToString:kFIRDefaultAppName]) {
|
||||
sDefaultApp = nil;
|
||||
}
|
||||
NSDictionary *appInfoDict = @{kFIRAppNameKey : self.name};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppDeleteNotification
|
||||
object:[self class]
|
||||
userInfo:appInfoDict];
|
||||
completion(YES);
|
||||
} else {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000007", @"App does not exist.");
|
||||
completion(NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)addAppToAppDictionary:(FIRApp *)app {
|
||||
if (!sAllApps) {
|
||||
sAllApps = [NSMutableDictionary dictionary];
|
||||
}
|
||||
if ([app configureCore]) {
|
||||
sAllApps[app.name] = app;
|
||||
} else {
|
||||
[NSException raise:kFirebaseCoreErrorDomain
|
||||
format:@"Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in "
|
||||
@"GoogleService-Info.plist or set in the customized options."];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_name = [name copy];
|
||||
_options = [options copy];
|
||||
_options.editingLocked = YES;
|
||||
_isDefaultApp = [name isEqualToString:kFIRDefaultAppName];
|
||||
_container = [[FIRComponentContainer alloc] initWithApp:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (BOOL)configureCore {
|
||||
[self checkExpectedBundleID];
|
||||
if (![self isAppIDValid]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
[self logCoreTelemetryIfEnabled];
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
// Initialize the Analytics once there is a valid options under default app. Analytics should
|
||||
// always initialize first by itself before the other SDKs.
|
||||
if ([self.name isEqualToString:kFIRDefaultAppName]) {
|
||||
Class firAnalyticsClass = NSClassFromString(@"FIRAnalytics");
|
||||
if (firAnalyticsClass) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wundeclared-selector"
|
||||
SEL startWithConfigurationSelector = @selector(startWithConfiguration:options:);
|
||||
#pragma clang diagnostic pop
|
||||
if ([firAnalyticsClass respondsToSelector:startWithConfigurationSelector]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[firAnalyticsClass performSelector:startWithConfigurationSelector
|
||||
withObject:[FIRConfiguration sharedInstance].analyticsConfiguration
|
||||
withObject:_options];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[self subscribeForAppDidBecomeActiveNotifications];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (FIROptions *)options {
|
||||
return [_options copy];
|
||||
}
|
||||
|
||||
- (void)setDataCollectionDefaultEnabled:(BOOL)dataCollectionDefaultEnabled {
|
||||
#ifdef DEBUG
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000034", @"Explicitly %@ data collection flag.",
|
||||
dataCollectionDefaultEnabled ? @"enabled" : @"disabled");
|
||||
self.alreadyOutputDataCollectionFlag = YES;
|
||||
#endif // DEBUG
|
||||
|
||||
NSString *key =
|
||||
[NSString stringWithFormat:kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat, self.name];
|
||||
[[NSUserDefaults standardUserDefaults] setBool:dataCollectionDefaultEnabled forKey:key];
|
||||
|
||||
// Core also controls the FirebaseAnalytics flag, so check if the Analytics flags are set
|
||||
// within FIROptions and change the Analytics value if necessary. Analytics only works with the
|
||||
// default app, so return if this isn't the default app.
|
||||
if (!self.isDefaultApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the Analytics flag is explicitly set. If so, no further actions are necessary.
|
||||
if ([self.options isAnalyticsCollectionExpicitlySet]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The Analytics flag has not been explicitly set, so update with the value being set.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[[FIRAnalyticsConfiguration sharedInstance]
|
||||
setAnalyticsCollectionEnabled:dataCollectionDefaultEnabled
|
||||
persistSetting:NO];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (BOOL)isDataCollectionDefaultEnabled {
|
||||
// Check if it's been manually set before in code, and use that as the higher priority value.
|
||||
NSNumber *defaultsObject = [[self class] readDataCollectionSwitchFromUserDefaultsForApp:self];
|
||||
if (defaultsObject != nil) {
|
||||
#ifdef DEBUG
|
||||
if (!self.alreadyOutputDataCollectionFlag) {
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000031", @"Data Collection flag is %@ in user defaults.",
|
||||
[defaultsObject boolValue] ? @"enabled" : @"disabled");
|
||||
self.alreadyOutputDataCollectionFlag = YES;
|
||||
}
|
||||
#endif // DEBUG
|
||||
return [defaultsObject boolValue];
|
||||
}
|
||||
|
||||
// Read the Info.plist to see if the flag is set. If it's not set, it should default to `YES`.
|
||||
// As per the implementation of `readDataCollectionSwitchFromPlist`, it's a cached value and has
|
||||
// no performance impact calling multiple times.
|
||||
NSNumber *collectionEnabledPlistValue = [[self class] readDataCollectionSwitchFromPlist];
|
||||
if (collectionEnabledPlistValue != nil) {
|
||||
#ifdef DEBUG
|
||||
if (!self.alreadyOutputDataCollectionFlag) {
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000032", @"Data Collection flag is %@ in plist.",
|
||||
[collectionEnabledPlistValue boolValue] ? @"enabled" : @"disabled");
|
||||
self.alreadyOutputDataCollectionFlag = YES;
|
||||
}
|
||||
#endif // DEBUG
|
||||
return [collectionEnabledPlistValue boolValue];
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!self.alreadyOutputDataCollectionFlag) {
|
||||
FIRLogDebug(kFIRLoggerCore, @"I-COR000033", @"Data Collection flag is not set.");
|
||||
self.alreadyOutputDataCollectionFlag = YES;
|
||||
}
|
||||
#endif // DEBUG
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - private
|
||||
|
||||
+ (void)sendNotificationsToSDKs:(FIRApp *)app {
|
||||
// TODO: Remove this notification once all SDKs are registered with `FIRCoreConfigurable`.
|
||||
NSNumber *isDefaultApp = [NSNumber numberWithBool:app.isDefaultApp];
|
||||
NSDictionary *appInfoDict = @{
|
||||
kFIRAppNameKey : app.name,
|
||||
kFIRAppIsDefaultAppKey : isDefaultApp,
|
||||
kFIRGoogleAppIDKey : app.options.googleAppID
|
||||
};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppReadyToConfigureSDKNotification
|
||||
object:self
|
||||
userInfo:appInfoDict];
|
||||
|
||||
// This is the new way of sending information to SDKs.
|
||||
// TODO: Do we want this on a background thread, maybe?
|
||||
@synchronized(self) {
|
||||
for (Class<FIRLibrary> library in sRegisteredAsConfigurable) {
|
||||
[library configureWithApp:app];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSError *)errorForMissingOptions {
|
||||
NSDictionary *errorDict = @{
|
||||
NSLocalizedDescriptionKey :
|
||||
@"Unable to parse GoogleService-Info.plist in order to configure services.",
|
||||
NSLocalizedRecoverySuggestionErrorKey :
|
||||
@"Check formatting and location of GoogleService-Info.plist."
|
||||
};
|
||||
return [NSError errorWithDomain:kFirebaseCoreErrorDomain
|
||||
code:FIRErrorCodeInvalidPlistFile
|
||||
userInfo:errorDict];
|
||||
}
|
||||
|
||||
+ (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain
|
||||
errorCode:(FIRErrorCode)code
|
||||
service:(NSString *)service
|
||||
reason:(NSString *)reason {
|
||||
NSString *description =
|
||||
[NSString stringWithFormat:@"Configuration failed for service %@.", service];
|
||||
NSDictionary *errorDict =
|
||||
@{NSLocalizedDescriptionKey : description, NSLocalizedFailureReasonErrorKey : reason};
|
||||
return [NSError errorWithDomain:domain code:code userInfo:errorDict];
|
||||
}
|
||||
|
||||
+ (NSError *)errorForInvalidAppID {
|
||||
NSDictionary *errorDict = @{
|
||||
NSLocalizedDescriptionKey : @"Unable to validate Google App ID",
|
||||
NSLocalizedRecoverySuggestionErrorKey :
|
||||
@"Check formatting and location of GoogleService-Info.plist or GoogleAppID set in the "
|
||||
@"customized options."
|
||||
};
|
||||
return [NSError errorWithDomain:kFirebaseCoreErrorDomain
|
||||
code:FIRErrorCodeInvalidAppID
|
||||
userInfo:errorDict];
|
||||
}
|
||||
|
||||
+ (BOOL)isDefaultAppConfigured {
|
||||
return (sDefaultApp != nil);
|
||||
}
|
||||
|
||||
+ (void)registerLibrary:(nonnull NSString *)name withVersion:(nonnull NSString *)version {
|
||||
// Create the set of characters which aren't allowed, only if this feature is used.
|
||||
NSMutableCharacterSet *allowedSet = [NSMutableCharacterSet alphanumericCharacterSet];
|
||||
[allowedSet addCharactersInString:@"-_."];
|
||||
NSCharacterSet *disallowedSet = [allowedSet invertedSet];
|
||||
// Make sure the library name and version strings do not contain unexpected characters, and
|
||||
// add the name/version pair to the dictionary.
|
||||
if ([name rangeOfCharacterFromSet:disallowedSet].location == NSNotFound &&
|
||||
[version rangeOfCharacterFromSet:disallowedSet].location == NSNotFound) {
|
||||
@synchronized(self) {
|
||||
if (!sLibraryVersions) {
|
||||
sLibraryVersions = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
sLibraryVersions[name] = version;
|
||||
}
|
||||
} else {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000027",
|
||||
@"The library name (%@) or version number (%@) contain invalid characters. "
|
||||
@"Only alphanumeric, dash, underscore and period characters are allowed.",
|
||||
name, version);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
|
||||
withName:(nonnull NSString *)name
|
||||
withVersion:(nonnull NSString *)version {
|
||||
// This is called at +load time, keep the work to a minimum.
|
||||
|
||||
// Ensure the class given conforms to the proper protocol.
|
||||
if (![(Class)library conformsToProtocol:@protocol(FIRLibrary)] ||
|
||||
![(Class)library respondsToSelector:@selector(componentsToRegister)]) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Class %@ attempted to register components, but it does not conform to "
|
||||
@"`FIRLibrary or provide a `componentsToRegister:` method.",
|
||||
library];
|
||||
}
|
||||
|
||||
[FIRComponentContainer registerAsComponentRegistrant:library];
|
||||
if ([(Class)library respondsToSelector:@selector(configureWithApp:)]) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sRegisteredAsConfigurable = [[NSMutableArray alloc] init];
|
||||
});
|
||||
@synchronized(self) {
|
||||
[sRegisteredAsConfigurable addObject:library];
|
||||
}
|
||||
}
|
||||
[self registerLibrary:name withVersion:version];
|
||||
}
|
||||
|
||||
+ (NSString *)firebaseUserAgent {
|
||||
@synchronized(self) {
|
||||
NSMutableArray<NSString *> *libraries =
|
||||
[[NSMutableArray<NSString *> alloc] initWithCapacity:sLibraryVersions.count];
|
||||
for (NSString *libraryName in sLibraryVersions) {
|
||||
[libraries addObject:[NSString stringWithFormat:@"%@/%@", libraryName,
|
||||
sLibraryVersions[libraryName]]];
|
||||
}
|
||||
[libraries sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
|
||||
return [libraries componentsJoinedByString:@" "];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)checkExpectedBundleID {
|
||||
NSArray *bundles = [FIRBundleUtil relevantBundles];
|
||||
NSString *expectedBundleID = [self expectedBundleID];
|
||||
// The checking is only done when the bundle ID is provided in the serviceInfo dictionary for
|
||||
// backward compatibility.
|
||||
if (expectedBundleID != nil && ![FIRBundleUtil hasBundleIdentifierPrefix:expectedBundleID
|
||||
inBundles:bundles]) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000008",
|
||||
@"The project's Bundle ID is inconsistent with "
|
||||
@"either the Bundle ID in '%@.%@', or the Bundle ID in the options if you are "
|
||||
@"using a customized options. To ensure that everything can be configured "
|
||||
@"correctly, you may need to make the Bundle IDs consistent. To continue with this "
|
||||
@"plist file, you may change your app's bundle identifier to '%@'. Or you can "
|
||||
@"download a new configuration file that matches your bundle identifier from %@ "
|
||||
@"and replace the current one.",
|
||||
kServiceInfoFileName, kServiceInfoFileType, expectedBundleID, kPlistURL);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - private - App ID Validation
|
||||
|
||||
/**
|
||||
* Validates the format and fingerprint of the app ID contained in GOOGLE_APP_ID in the plist file.
|
||||
* This is the main method for validating app ID.
|
||||
*
|
||||
* @return YES if the app ID fulfills the expected format and fingerprint, NO otherwise.
|
||||
*/
|
||||
- (BOOL)isAppIDValid {
|
||||
NSString *appID = _options.googleAppID;
|
||||
BOOL isValid = [FIRApp validateAppID:appID];
|
||||
if (!isValid) {
|
||||
NSString *expectedBundleID = [self expectedBundleID];
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000009",
|
||||
@"The GOOGLE_APP_ID either in the plist file "
|
||||
@"'%@.%@' or the one set in the customized options is invalid. If you are using "
|
||||
@"the plist file, use the iOS version of bundle identifier to download the file, "
|
||||
@"and do not manually edit the GOOGLE_APP_ID. You may change your app's bundle "
|
||||
@"identifier to '%@'. Or you can download a new configuration file that matches "
|
||||
@"your bundle identifier from %@ and replace the current one.",
|
||||
kServiceInfoFileName, kServiceInfoFileType, expectedBundleID, kPlistURL);
|
||||
};
|
||||
return isValid;
|
||||
}
|
||||
|
||||
+ (BOOL)validateAppID:(NSString *)appID {
|
||||
// Failing validation only occurs when we are sure we are looking at a V2 app ID and it does not
|
||||
// have a valid fingerprint, otherwise we just warn about the potential issue.
|
||||
if (!appID.length) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSScanner *stringScanner = [NSScanner scannerWithString:appID];
|
||||
stringScanner.charactersToBeSkipped = nil;
|
||||
|
||||
NSString *appIDVersion;
|
||||
if (![stringScanner scanCharactersFromSet:[NSCharacterSet decimalDigitCharacterSet]
|
||||
intoString:&appIDVersion]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![stringScanner scanString:@":" intoString:NULL]) {
|
||||
// appIDVersion must be separated by ":"
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSArray *knownVersions = @[ @"1" ];
|
||||
if (![knownVersions containsObject:appIDVersion]) {
|
||||
// Permit unknown yet properly formatted app ID versions.
|
||||
FIRLogInfo(kFIRLoggerCore, @"I-COR000010", @"Unknown GOOGLE_APP_ID version: %@", appIDVersion);
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (![self validateAppIDFormat:appID withVersion:appIDVersion]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![self validateAppIDFingerprint:appID withVersion:appIDVersion]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (NSString *)actualBundleID {
|
||||
return [[NSBundle mainBundle] bundleIdentifier];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the format of the app ID string is what is expected based on the supplied version.
|
||||
* The version must end in ":".
|
||||
*
|
||||
* For v1 app ids the format is expected to be
|
||||
* '<version #>:<project number>:ios:<fingerprint of bundle id>'.
|
||||
*
|
||||
* This method does not verify that the contents of the app id are correct, just that they fulfill
|
||||
* the expected format.
|
||||
*
|
||||
* @param appID Contents of GOOGLE_APP_ID from the plist file.
|
||||
* @param version Indicates what version of the app id format this string should be.
|
||||
* @return YES if provided string fufills the expected format, NO otherwise.
|
||||
*/
|
||||
+ (BOOL)validateAppIDFormat:(NSString *)appID withVersion:(NSString *)version {
|
||||
if (!appID.length || !version.length) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSScanner *stringScanner = [NSScanner scannerWithString:appID];
|
||||
stringScanner.charactersToBeSkipped = nil;
|
||||
|
||||
// Skip version part
|
||||
// '*<version #>*:<project number>:ios:<fingerprint of bundle id>'
|
||||
if (![stringScanner scanString:version intoString:NULL]) {
|
||||
// The version part is missing or mismatched
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>*:*<project number>:ios:<fingerprint of bundle id>'
|
||||
if (![stringScanner scanString:@":" intoString:NULL]) {
|
||||
// appIDVersion must be separated by ":"
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>:*<project number>*:ios:<fingerprint of bundle id>'.
|
||||
NSInteger projectNumber = NSNotFound;
|
||||
if (![stringScanner scanInteger:&projectNumber]) {
|
||||
// NO project number found.
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>:<project number>*:*ios:<fingerprint of bundle id>'.
|
||||
if (![stringScanner scanString:@":" intoString:NULL]) {
|
||||
// The project number must be separated by ":"
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>:<project number>:*ios*:<fingerprint of bundle id>'.
|
||||
NSString *platform;
|
||||
if (![stringScanner scanUpToString:@":" intoString:&platform]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![platform isEqualToString:@"ios"]) {
|
||||
// The platform must be @"ios"
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>:<project number>:ios*:*<fingerprint of bundle id>'.
|
||||
if (![stringScanner scanString:@":" intoString:NULL]) {
|
||||
// The platform must be separated by ":"
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Validate version part (see part between '*' symbols below)
|
||||
// '<version #>:<project number>:ios:*<fingerprint of bundle id>*'.
|
||||
unsigned long long fingerprint = NSNotFound;
|
||||
if (![stringScanner scanHexLongLong:&fingerprint]) {
|
||||
// Fingerprint part is missing
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!stringScanner.isAtEnd) {
|
||||
// There are not allowed characters in the fingerprint part
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the fingerprint of the app ID string is what is expected based on the supplied
|
||||
* version.
|
||||
*
|
||||
* Note that the v1 hash algorithm is not permitted on the client and cannot be fully validated.
|
||||
*
|
||||
* @param appID Contents of GOOGLE_APP_ID from the plist file.
|
||||
* @param version Indicates what version of the app id format this string should be.
|
||||
* @return YES if provided string fufills the expected fingerprint and the version is known, NO
|
||||
* otherwise.
|
||||
*/
|
||||
+ (BOOL)validateAppIDFingerprint:(NSString *)appID withVersion:(NSString *)version {
|
||||
// Extract the supplied fingerprint from the supplied app ID.
|
||||
// This assumes the app ID format is the same for all known versions below. If the app ID format
|
||||
// changes in future versions, the tokenizing of the app ID format will need to take into account
|
||||
// the version of the app ID.
|
||||
NSArray *components = [appID componentsSeparatedByString:@":"];
|
||||
if (components.count != 4) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *suppliedFingerprintString = components[3];
|
||||
if (!suppliedFingerprintString.length) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
uint64_t suppliedFingerprint;
|
||||
NSScanner *scanner = [NSScanner scannerWithString:suppliedFingerprintString];
|
||||
if (![scanner scanHexLongLong:&suppliedFingerprint]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([version isEqual:@"1"]) {
|
||||
// The v1 hash algorithm is not permitted on the client so the actual hash cannot be validated.
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Unknown version.
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)expectedBundleID {
|
||||
return _options.bundleID;
|
||||
}
|
||||
|
||||
// end App ID validation
|
||||
|
||||
#pragma mark - Reading From Plist & User Defaults
|
||||
|
||||
/**
|
||||
* Clears the data collection switch from the standard NSUserDefaults for easier testing and
|
||||
* readability.
|
||||
*/
|
||||
- (void)clearDataCollectionSwitchFromUserDefaults {
|
||||
NSString *key =
|
||||
[NSString stringWithFormat:kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat, self.name];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the data collection switch from the standard NSUserDefaults for easier testing and
|
||||
* readability.
|
||||
*/
|
||||
+ (nullable NSNumber *)readDataCollectionSwitchFromUserDefaultsForApp:(FIRApp *)app {
|
||||
// Read the object in user defaults, and only return if it's an NSNumber.
|
||||
NSString *key =
|
||||
[NSString stringWithFormat:kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat, app.name];
|
||||
id collectionEnabledDefaultsObject = [[NSUserDefaults standardUserDefaults] objectForKey:key];
|
||||
if ([collectionEnabledDefaultsObject isKindOfClass:[NSNumber class]]) {
|
||||
return collectionEnabledDefaultsObject;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the data collection switch from the Info.plist for easier testing and readability. Will
|
||||
* only read once from the plist and return the cached value.
|
||||
*/
|
||||
+ (nullable NSNumber *)readDataCollectionSwitchFromPlist {
|
||||
static NSNumber *collectionEnabledPlistObject;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
// Read the data from the `Info.plist`, only assign it if it's there and an NSNumber.
|
||||
id plistValue = [[NSBundle mainBundle]
|
||||
objectForInfoDictionaryKey:kFIRGlobalAppDataCollectionEnabledPlistKey];
|
||||
if (plistValue && [plistValue isKindOfClass:[NSNumber class]]) {
|
||||
collectionEnabledPlistObject = (NSNumber *)plistValue;
|
||||
}
|
||||
});
|
||||
|
||||
return collectionEnabledPlistObject;
|
||||
}
|
||||
|
||||
#pragma mark - Sending Logs
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
- (void)sendLogsWithServiceName:(NSString *)serviceName
|
||||
version:(NSString *)version
|
||||
error:(NSError *)error {
|
||||
// Do nothing. Please remove calls to this method.
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma mark - App Life Cycle
|
||||
|
||||
- (void)subscribeForAppDidBecomeActiveNotifications {
|
||||
#if TARGET_OS_IOS || TARGET_OS_TV
|
||||
NSNotificationName notificationName = UIApplicationDidBecomeActiveNotification;
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_OSX
|
||||
NSNotificationName notificationName = NSApplicationDidBecomeActiveNotification;
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(appDidBecomeActive:)
|
||||
name:notificationName
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)appDidBecomeActive:(NSNotification *)notification {
|
||||
[self logCoreTelemetryIfEnabled];
|
||||
}
|
||||
|
||||
- (void)logCoreTelemetryIfEnabled {
|
||||
if ([self isDataCollectionDefaultEnabled]) {
|
||||
[FIRCoreDiagnosticsConnector logCoreTelemetryWithOptions:_options];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRAppAssociationRegistration.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@implementation FIRAppAssociationRegistration
|
||||
|
||||
+ (nullable id)registeredObjectWithHost:(id)host
|
||||
key:(NSString *)key
|
||||
creationBlock:(id _Nullable (^)(void))creationBlock {
|
||||
@synchronized(self) {
|
||||
SEL dictKey = @selector(registeredObjectWithHost:key:creationBlock:);
|
||||
NSMutableDictionary<NSString *, id> *objectsByKey = objc_getAssociatedObject(host, dictKey);
|
||||
if (!objectsByKey) {
|
||||
objectsByKey = [[NSMutableDictionary alloc] init];
|
||||
objc_setAssociatedObject(host, dictKey, objectsByKey, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
id obj = objectsByKey[key];
|
||||
NSValue *creationBlockBeingCalled = [NSValue valueWithPointer:dictKey];
|
||||
if (obj) {
|
||||
if ([creationBlockBeingCalled isEqual:obj]) {
|
||||
[NSException raise:@"Reentering registeredObjectWithHost:key:creationBlock: not allowed"
|
||||
format:@"host: %@ key: %@", host, key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
objectsByKey[key] = creationBlockBeingCalled;
|
||||
obj = creationBlock();
|
||||
objectsByKey[key] = obj;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRBundleUtil.h"
|
||||
|
||||
#import <GoogleUtilities/GULAppEnvironmentUtil.h>
|
||||
|
||||
@implementation FIRBundleUtil
|
||||
|
||||
+ (NSArray *)relevantBundles {
|
||||
return @[ [NSBundle mainBundle], [NSBundle bundleForClass:[self class]] ];
|
||||
}
|
||||
|
||||
+ (NSString *)optionsDictionaryPathWithResourceName:(NSString *)resourceName
|
||||
andFileType:(NSString *)fileType
|
||||
inBundles:(NSArray *)bundles {
|
||||
// Loop through all bundles to find the config dict.
|
||||
for (NSBundle *bundle in bundles) {
|
||||
NSString *path = [bundle pathForResource:resourceName ofType:fileType];
|
||||
// Use the first one we find.
|
||||
if (path) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSArray *)relevantURLSchemes {
|
||||
NSMutableArray *result = [[NSMutableArray alloc] init];
|
||||
for (NSBundle *bundle in [[self class] relevantBundles]) {
|
||||
NSArray *urlTypes = [bundle objectForInfoDictionaryKey:@"CFBundleURLTypes"];
|
||||
for (NSDictionary *urlType in urlTypes) {
|
||||
[result addObjectsFromArray:urlType[@"CFBundleURLSchemes"]];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
|
||||
for (NSBundle *bundle in bundles) {
|
||||
// This allows app extensions that have the app's bundle as their prefix to pass this test.
|
||||
NSString *applicationBundleIdentifier =
|
||||
[GULAppEnvironmentUtil isAppExtension]
|
||||
? [self bundleIdentifierByRemovingLastPartFrom:bundle.bundleIdentifier]
|
||||
: bundle.bundleIdentifier;
|
||||
|
||||
if ([applicationBundleIdentifier isEqualToString:bundleIdentifier]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (NSString *)bundleIdentifierByRemovingLastPartFrom:(NSString *)bundleIdentifier {
|
||||
NSString *bundleIDComponentsSeparator = @".";
|
||||
|
||||
NSMutableArray<NSString *> *bundleIDComponents =
|
||||
[[bundleIdentifier componentsSeparatedByString:bundleIDComponentsSeparator] mutableCopy];
|
||||
[bundleIDComponents removeLastObject];
|
||||
|
||||
return [bundleIDComponents componentsJoinedByString:bundleIDComponentsSeparator];
|
||||
}
|
||||
|
||||
@end
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRComponent.h"
|
||||
|
||||
#import "Private/FIRComponentContainer.h"
|
||||
#import "Private/FIRDependency.h"
|
||||
|
||||
@interface FIRComponent ()
|
||||
|
||||
- (instancetype)initWithProtocol:(Protocol *)protocol
|
||||
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
|
||||
dependencies:(NSArray<FIRDependency *> *)dependencies
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRComponent
|
||||
|
||||
+ (instancetype)componentWithProtocol:(Protocol *)protocol
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock {
|
||||
return [[FIRComponent alloc] initWithProtocol:protocol
|
||||
instantiationTiming:FIRInstantiationTimingLazy
|
||||
dependencies:@[]
|
||||
creationBlock:creationBlock];
|
||||
}
|
||||
|
||||
+ (instancetype)componentWithProtocol:(Protocol *)protocol
|
||||
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
|
||||
dependencies:(NSArray<FIRDependency *> *)dependencies
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock {
|
||||
return [[FIRComponent alloc] initWithProtocol:protocol
|
||||
instantiationTiming:instantiationTiming
|
||||
dependencies:dependencies
|
||||
creationBlock:creationBlock];
|
||||
}
|
||||
|
||||
- (instancetype)initWithProtocol:(Protocol *)protocol
|
||||
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
|
||||
dependencies:(NSArray<FIRDependency *> *)dependencies
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_protocol = protocol;
|
||||
_instantiationTiming = instantiationTiming;
|
||||
_dependencies = [dependencies copy];
|
||||
_creationBlock = creationBlock;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRComponentContainer.h"
|
||||
|
||||
#import "Private/FIRAppInternal.h"
|
||||
#import "Private/FIRComponent.h"
|
||||
#import "Private/FIRLibrary.h"
|
||||
#import "Private/FIRLogger.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRComponentContainer ()
|
||||
|
||||
/// The dictionary of components that are registered for a particular app. The key is an NSString
|
||||
/// of the protocol.
|
||||
@property(nonatomic, strong) NSMutableDictionary<NSString *, FIRComponentCreationBlock> *components;
|
||||
|
||||
/// Cached instances of components that requested to be cached.
|
||||
@property(nonatomic, strong) NSMutableDictionary<NSString *, id> *cachedInstances;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRComponentContainer
|
||||
|
||||
// Collection of all classes that register to provide components.
|
||||
static NSMutableSet<Class> *sFIRComponentRegistrants;
|
||||
|
||||
#pragma mark - Public Registration
|
||||
|
||||
+ (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sFIRComponentRegistrants = [[NSMutableSet<Class> alloc] init];
|
||||
});
|
||||
|
||||
[self registerAsComponentRegistrant:klass inSet:sFIRComponentRegistrants];
|
||||
}
|
||||
|
||||
+ (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass
|
||||
inSet:(NSMutableSet<Class> *)allRegistrants {
|
||||
[allRegistrants addObject:klass];
|
||||
}
|
||||
|
||||
#pragma mark - Internal Initialization
|
||||
|
||||
- (instancetype)initWithApp:(FIRApp *)app {
|
||||
return [self initWithApp:app registrants:sFIRComponentRegistrants];
|
||||
}
|
||||
|
||||
- (instancetype)initWithApp:(FIRApp *)app registrants:(NSMutableSet<Class> *)allRegistrants {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_app = app;
|
||||
_cachedInstances = [NSMutableDictionary<NSString *, id> dictionary];
|
||||
_components = [NSMutableDictionary<NSString *, FIRComponentCreationBlock> dictionary];
|
||||
|
||||
[self populateComponentsFromRegisteredClasses:allRegistrants forApp:app];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)populateComponentsFromRegisteredClasses:(NSSet<Class> *)classes forApp:(FIRApp *)app {
|
||||
// Loop through the verified component registrants and populate the components array.
|
||||
for (Class<FIRLibrary> klass in classes) {
|
||||
// Loop through all the components being registered and store them as appropriate.
|
||||
// Classes which do not provide functionality should use a dummy FIRComponentRegistrant
|
||||
// protocol.
|
||||
for (FIRComponent *component in [klass componentsToRegister]) {
|
||||
// Check if the component has been registered before, and error out if so.
|
||||
NSString *protocolName = NSStringFromProtocol(component.protocol);
|
||||
if (self.components[protocolName]) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000029",
|
||||
@"Attempted to register protocol %@, but it already has an implementation.",
|
||||
protocolName);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Store the creation block for later usage.
|
||||
self.components[protocolName] = component.creationBlock;
|
||||
|
||||
// Instantiate the
|
||||
BOOL shouldInstantiateEager =
|
||||
(component.instantiationTiming == FIRInstantiationTimingAlwaysEager);
|
||||
BOOL shouldInstantiateDefaultEager =
|
||||
(component.instantiationTiming == FIRInstantiationTimingEagerInDefaultApp &&
|
||||
[app isDefaultApp]);
|
||||
if (shouldInstantiateEager || shouldInstantiateDefaultEager) {
|
||||
[self instantiateInstanceForProtocol:component.protocol withBlock:component.creationBlock];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Instance Creation
|
||||
|
||||
/// Instantiate an instance of a class that conforms to the specified protocol.
|
||||
/// This will:
|
||||
/// - Call the block to create an instance if possible,
|
||||
/// - Validate that the instance returned conforms to the protocol it claims to,
|
||||
/// - Cache the instance if the block requests it
|
||||
- (nullable id)instantiateInstanceForProtocol:(Protocol *)protocol
|
||||
withBlock:(FIRComponentCreationBlock)creationBlock {
|
||||
if (!creationBlock) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Create an instance using the creation block.
|
||||
BOOL shouldCache = NO;
|
||||
id instance = creationBlock(self, &shouldCache);
|
||||
if (!instance) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// An instance was created, validate that it conforms to the protocol it claims to.
|
||||
NSString *protocolName = NSStringFromProtocol(protocol);
|
||||
if (![instance conformsToProtocol:protocol]) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000030",
|
||||
@"An instance conforming to %@ was requested, but the instance provided does not "
|
||||
@"conform to the protocol",
|
||||
protocolName);
|
||||
}
|
||||
|
||||
// The instance is ready to be returned, but check if it should be cached first before returning.
|
||||
if (shouldCache) {
|
||||
self.cachedInstances[protocolName] = instance;
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
#pragma mark - Internal Retrieval
|
||||
|
||||
- (nullable id)instanceForProtocol:(Protocol *)protocol {
|
||||
// Check if there is a cached instance, and return it if so.
|
||||
NSString *protocolName = NSStringFromProtocol(protocol);
|
||||
id cachedInstance = self.cachedInstances[protocolName];
|
||||
if (cachedInstance) {
|
||||
return cachedInstance;
|
||||
}
|
||||
|
||||
// Use the creation block to instantiate an instance and return it.
|
||||
FIRComponentCreationBlock creationBlock = self.components[protocolName];
|
||||
return [self instantiateInstanceForProtocol:protocol withBlock:creationBlock];
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (void)removeAllCachedInstances {
|
||||
// Loop through the cache and notify each instance that is a maintainer to clean up after itself.
|
||||
for (id instance in self.cachedInstances.allValues) {
|
||||
if ([instance conformsToProtocol:@protocol(FIRComponentLifecycleMaintainer)] &&
|
||||
[instance respondsToSelector:@selector(appWillBeDeleted:)]) {
|
||||
[instance appWillBeDeleted:self.app];
|
||||
}
|
||||
}
|
||||
|
||||
[self.cachedInstances removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRComponentType.h"
|
||||
|
||||
#import "Private/FIRComponentContainerInternal.h"
|
||||
|
||||
@implementation FIRComponentType
|
||||
|
||||
+ (id)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container {
|
||||
// Forward the call to the container.
|
||||
return [container instanceForProtocol:protocol];
|
||||
}
|
||||
|
||||
@end
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRConfigurationInternal.h"
|
||||
|
||||
#import "Private/FIRAnalyticsConfiguration.h"
|
||||
|
||||
extern void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
|
||||
|
||||
@implementation FIRConfiguration
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static FIRConfiguration *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[FIRConfiguration alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_analyticsConfiguration = [FIRAnalyticsConfiguration sharedInstance];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel {
|
||||
NSAssert(loggerLevel <= FIRLoggerLevelMax && loggerLevel >= FIRLoggerLevelMin,
|
||||
@"Invalid logger level, %ld", (long)loggerLevel);
|
||||
FIRSetLoggerLevel(loggerLevel);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRCoreDiagnosticsConnector.h"
|
||||
|
||||
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsInterop.h>
|
||||
|
||||
#import <FirebaseCore/FIROptions.h>
|
||||
|
||||
#import "Private/FIRAppInternal.h"
|
||||
#import "Private/FIRDiagnosticsData.h"
|
||||
#import "Private/FIROptionsInternal.h"
|
||||
|
||||
// Define the interop class symbol declared as an extern in FIRCoreDiagnosticsInterop.
|
||||
Class<FIRCoreDiagnosticsInterop> FIRCoreDiagnosticsImplementation;
|
||||
|
||||
@implementation FIRCoreDiagnosticsConnector
|
||||
|
||||
+ (void)initialize {
|
||||
if (!FIRCoreDiagnosticsImplementation) {
|
||||
FIRCoreDiagnosticsImplementation = NSClassFromString(@"FIRCoreDiagnostics");
|
||||
if (FIRCoreDiagnosticsImplementation) {
|
||||
NSAssert([FIRCoreDiagnosticsImplementation
|
||||
conformsToProtocol:@protocol(FIRCoreDiagnosticsInterop)],
|
||||
@"If FIRCoreDiagnostics is implemented, it must conform to the interop protocol.");
|
||||
NSAssert(
|
||||
[FIRCoreDiagnosticsImplementation respondsToSelector:@selector(sendDiagnosticsData:)],
|
||||
@"If FIRCoreDiagnostics is implemented, it must implement +sendDiagnosticsData.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)logCoreTelemetryWithOptions:(FIROptions *)options {
|
||||
if (FIRCoreDiagnosticsImplementation) {
|
||||
FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
|
||||
[diagnosticsData insertValue:@(YES) forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
|
||||
[diagnosticsData insertValue:[FIRApp firebaseUserAgent] forKey:kFIRCDFirebaseUserAgentKey];
|
||||
[diagnosticsData insertValue:@(FIRConfigTypeCore) forKey:kFIRCDConfigurationTypeKey];
|
||||
[diagnosticsData insertValue:options.googleAppID forKey:kFIRCDGoogleAppIDKey];
|
||||
[diagnosticsData insertValue:options.bundleID forKey:kFIRCDBundleIDKey];
|
||||
[diagnosticsData insertValue:@(options.usingOptionsFromDefaultPlist)
|
||||
forKey:kFIRCDUsingOptionsFromDefaultPlistKey];
|
||||
[diagnosticsData insertValue:options.libraryVersionID forKey:kFIRCDLibraryVersionIDKey];
|
||||
[FIRCoreDiagnosticsImplementation sendDiagnosticsData:diagnosticsData];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRDependency.h"
|
||||
|
||||
@interface FIRDependency ()
|
||||
|
||||
- (instancetype)initWithProtocol:(Protocol *)protocol isRequired:(BOOL)required;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIRDependency
|
||||
|
||||
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol {
|
||||
return [[self alloc] initWithProtocol:protocol isRequired:YES];
|
||||
}
|
||||
|
||||
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol isRequired:(BOOL)required {
|
||||
return [[self alloc] initWithProtocol:protocol isRequired:required];
|
||||
}
|
||||
|
||||
- (instancetype)initWithProtocol:(Protocol *)protocol isRequired:(BOOL)required {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_protocol = protocol;
|
||||
_isRequired = required;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "Private/FIRDiagnosticsData.h"
|
||||
|
||||
#import <FirebaseCore/FIRApp.h>
|
||||
|
||||
#import "Private/FIRAppInternal.h"
|
||||
#import "Private/FIROptionsInternal.h"
|
||||
|
||||
@implementation FIRDiagnosticsData {
|
||||
/** Backing ivar for the diagnosticObjects property. */
|
||||
NSMutableDictionary<NSString *, id> *_diagnosticObjects;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_diagnosticObjects = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)insertValue:(nullable id)value forKey:(NSString *)key {
|
||||
if (key) {
|
||||
_diagnosticObjects[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FIRCoreDiagnosticsData
|
||||
|
||||
- (NSDictionary<NSString *, id> *)diagnosticObjects {
|
||||
if (!_diagnosticObjects[kFIRCDllAppsCountKey]) {
|
||||
_diagnosticObjects[kFIRCDllAppsCountKey] = @([FIRApp allApps].count);
|
||||
}
|
||||
if (!_diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]) {
|
||||
_diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey] =
|
||||
@([[FIRApp defaultApp] isDataCollectionDefaultEnabled]);
|
||||
}
|
||||
if (!_diagnosticObjects[kFIRCDFirebaseUserAgentKey]) {
|
||||
_diagnosticObjects[kFIRCDFirebaseUserAgentKey] = [FIRApp firebaseUserAgent];
|
||||
}
|
||||
return _diagnosticObjects;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
- (void)setDiagnosticObjects:(NSDictionary<NSString *, id> *)diagnosticObjects {
|
||||
NSAssert(NO, @"Please use -insertValue:forKey:");
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRErrors.h"
|
||||
|
||||
NSString *const kFirebaseErrorDomain = @"com.firebase";
|
||||
NSString *const kFirebaseConfigErrorDomain = @"com.firebase.config";
|
||||
NSString *const kFirebaseCoreErrorDomain = @"com.firebase.core";
|
||||
NSString *const kFirebasePerfErrorDomain = @"com.firebase.perf";
|
||||
NSString *const kFirebaseStorageErrorDomain = @"com.firebase.storage";
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRLogger.h"
|
||||
|
||||
#import <FirebaseCore/FIRLoggerLevel.h>
|
||||
#import <GoogleUtilities/GULAppEnvironmentUtil.h>
|
||||
#import <GoogleUtilities/GULLogger.h>
|
||||
|
||||
#import "Private/FIRVersion.h"
|
||||
|
||||
FIRLoggerService kFIRLoggerCore = @"[Firebase/Core]";
|
||||
|
||||
// All the FIRLoggerService definitions should be migrated to clients. Do not add new ones!
|
||||
FIRLoggerService kFIRLoggerABTesting = @"[Firebase/ABTesting]";
|
||||
FIRLoggerService kFIRLoggerAdMob = @"[Firebase/AdMob]";
|
||||
FIRLoggerService kFIRLoggerAnalytics = @"[Firebase/Analytics]";
|
||||
FIRLoggerService kFIRLoggerAuth = @"[Firebase/Auth]";
|
||||
FIRLoggerService kFIRLoggerCrash = @"[Firebase/Crash]";
|
||||
FIRLoggerService kFIRLoggerMLKit = @"[Firebase/MLKit]";
|
||||
FIRLoggerService kFIRLoggerPerf = @"[Firebase/Performance]";
|
||||
FIRLoggerService kFIRLoggerRemoteConfig = @"[Firebase/RemoteConfig]";
|
||||
|
||||
/// Arguments passed on launch.
|
||||
NSString *const kFIRDisableDebugModeApplicationArgument = @"-FIRDebugDisabled";
|
||||
NSString *const kFIREnableDebugModeApplicationArgument = @"-FIRDebugEnabled";
|
||||
NSString *const kFIRLoggerForceSDTERRApplicationArgument = @"-FIRLoggerForceSTDERR";
|
||||
|
||||
/// Key for the debug mode bit in NSUserDefaults.
|
||||
NSString *const kFIRPersistedDebugModeKey = @"/google/firebase/debug_mode";
|
||||
|
||||
/// NSUserDefaults that should be used to store and read variables. If nil, `standardUserDefaults`
|
||||
/// will be used.
|
||||
static NSUserDefaults *sFIRLoggerUserDefaults;
|
||||
|
||||
static dispatch_once_t sFIRLoggerOnceToken;
|
||||
|
||||
// The sFIRAnalyticsDebugMode flag is here to support the -FIRDebugEnabled/-FIRDebugDisabled
|
||||
// flags used by Analytics. Users who use those flags expect Analytics to log verbosely,
|
||||
// while the rest of Firebase logs at the default level. This flag is introduced to support
|
||||
// that behavior.
|
||||
static BOOL sFIRAnalyticsDebugMode;
|
||||
|
||||
#ifdef DEBUG
|
||||
/// The regex pattern for the message code.
|
||||
static NSString *const kMessageCodePattern = @"^I-[A-Z]{3}[0-9]{6}$";
|
||||
static NSRegularExpression *sMessageCodeRegex;
|
||||
#endif
|
||||
|
||||
void FIRLoggerInitializeASL() {
|
||||
dispatch_once(&sFIRLoggerOnceToken, ^{
|
||||
// Register Firebase Version with GULLogger.
|
||||
GULLoggerRegisterVersion(FIRVersionString);
|
||||
|
||||
// Override the aslOptions to ASL_OPT_STDERR if the override argument is passed in.
|
||||
NSArray *arguments = [NSProcessInfo processInfo].arguments;
|
||||
BOOL overrideSTDERR = [arguments containsObject:kFIRLoggerForceSDTERRApplicationArgument];
|
||||
|
||||
// Use the standard NSUserDefaults if it hasn't been explicitly set.
|
||||
if (sFIRLoggerUserDefaults == nil) {
|
||||
sFIRLoggerUserDefaults = [NSUserDefaults standardUserDefaults];
|
||||
}
|
||||
|
||||
BOOL forceDebugMode = NO;
|
||||
BOOL debugMode = [sFIRLoggerUserDefaults boolForKey:kFIRPersistedDebugModeKey];
|
||||
if ([arguments containsObject:kFIRDisableDebugModeApplicationArgument]) { // Default mode
|
||||
[sFIRLoggerUserDefaults removeObjectForKey:kFIRPersistedDebugModeKey];
|
||||
} else if ([arguments containsObject:kFIREnableDebugModeApplicationArgument] ||
|
||||
debugMode) { // Debug mode
|
||||
[sFIRLoggerUserDefaults setBool:YES forKey:kFIRPersistedDebugModeKey];
|
||||
forceDebugMode = YES;
|
||||
}
|
||||
GULLoggerInitializeASL();
|
||||
if (overrideSTDERR) {
|
||||
GULLoggerEnableSTDERR();
|
||||
}
|
||||
if (forceDebugMode) {
|
||||
GULLoggerForceDebug();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
__attribute__((no_sanitize("thread"))) void FIRSetAnalyticsDebugMode(BOOL analyticsDebugMode) {
|
||||
sFIRAnalyticsDebugMode = analyticsDebugMode;
|
||||
}
|
||||
|
||||
void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel) {
|
||||
FIRLoggerInitializeASL();
|
||||
GULSetLoggerLevel((GULLoggerLevel)loggerLevel);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void FIRResetLogger() {
|
||||
extern void GULResetLogger(void);
|
||||
sFIRLoggerOnceToken = 0;
|
||||
[sFIRLoggerUserDefaults removeObjectForKey:kFIRPersistedDebugModeKey];
|
||||
sFIRLoggerUserDefaults = nil;
|
||||
GULResetLogger();
|
||||
}
|
||||
|
||||
void FIRSetLoggerUserDefaults(NSUserDefaults *defaults) {
|
||||
sFIRLoggerUserDefaults = defaults;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check if the level is high enough to be loggable.
|
||||
*
|
||||
* Analytics can override the log level with an intentional race condition.
|
||||
* Add the attribute to get a clean thread sanitizer run.
|
||||
*/
|
||||
__attribute__((no_sanitize("thread"))) BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel,
|
||||
BOOL analyticsComponent) {
|
||||
FIRLoggerInitializeASL();
|
||||
if (sFIRAnalyticsDebugMode && analyticsComponent) {
|
||||
return YES;
|
||||
}
|
||||
return GULIsLoggableLevel((GULLoggerLevel)loggerLevel);
|
||||
}
|
||||
|
||||
void FIRLogBasic(FIRLoggerLevel level,
|
||||
FIRLoggerService service,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
va_list args_ptr) {
|
||||
FIRLoggerInitializeASL();
|
||||
GULLogBasic((GULLoggerLevel)level, service,
|
||||
sFIRAnalyticsDebugMode && [kFIRLoggerAnalytics isEqualToString:service], messageCode,
|
||||
message, args_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the logging functions using macros.
|
||||
*
|
||||
* Calling FIRLogError(kFIRLoggerCore, @"I-COR000001", @"Configure %@ failed.", @"blah") shows:
|
||||
* yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Error> [Firebase/Core][I-COR000001] Configure blah failed.
|
||||
* Calling FIRLogDebug(kFIRLoggerCore, @"I-COR000001", @"Configure succeed.") shows:
|
||||
* yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Debug> [Firebase/Core][I-COR000001] Configure succeed.
|
||||
*/
|
||||
#define FIR_LOGGING_FUNCTION(level) \
|
||||
void FIRLog##level(FIRLoggerService service, NSString *messageCode, NSString *message, ...) { \
|
||||
va_list args_ptr; \
|
||||
va_start(args_ptr, message); \
|
||||
FIRLogBasic(FIRLoggerLevel##level, service, messageCode, message, args_ptr); \
|
||||
va_end(args_ptr); \
|
||||
}
|
||||
|
||||
FIR_LOGGING_FUNCTION(Error)
|
||||
FIR_LOGGING_FUNCTION(Warning)
|
||||
FIR_LOGGING_FUNCTION(Notice)
|
||||
FIR_LOGGING_FUNCTION(Info)
|
||||
FIR_LOGGING_FUNCTION(Debug)
|
||||
|
||||
#undef FIR_MAKE_LOGGER
|
||||
|
||||
#pragma mark - FIRLoggerWrapper
|
||||
|
||||
@implementation FIRLoggerWrapper
|
||||
|
||||
+ (void)logWithLevel:(FIRLoggerLevel)level
|
||||
withService:(FIRLoggerService)service
|
||||
withCode:(NSString *)messageCode
|
||||
withMessage:(NSString *)message
|
||||
withArgs:(va_list)args {
|
||||
FIRLogBasic(level, service, messageCode, message, args);
|
||||
}
|
||||
|
||||
@end
|
||||
+454
@@ -0,0 +1,454 @@
|
||||
// Copyright 2017 Google
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#import "Private/FIRAppInternal.h"
|
||||
#import "Private/FIRBundleUtil.h"
|
||||
#import "Private/FIRErrors.h"
|
||||
#import "Private/FIRLogger.h"
|
||||
#import "Private/FIROptionsInternal.h"
|
||||
#import "Private/FIRVersion.h"
|
||||
|
||||
// Keys for the strings in the plist file.
|
||||
NSString *const kFIRAPIKey = @"API_KEY";
|
||||
NSString *const kFIRTrackingID = @"TRACKING_ID";
|
||||
NSString *const kFIRGoogleAppID = @"GOOGLE_APP_ID";
|
||||
NSString *const kFIRClientID = @"CLIENT_ID";
|
||||
NSString *const kFIRGCMSenderID = @"GCM_SENDER_ID";
|
||||
NSString *const kFIRAndroidClientID = @"ANDROID_CLIENT_ID";
|
||||
NSString *const kFIRDatabaseURL = @"DATABASE_URL";
|
||||
NSString *const kFIRStorageBucket = @"STORAGE_BUCKET";
|
||||
// The key to locate the expected bundle identifier in the plist file.
|
||||
NSString *const kFIRBundleID = @"BUNDLE_ID";
|
||||
// The key to locate the project identifier in the plist file.
|
||||
NSString *const kFIRProjectID = @"PROJECT_ID";
|
||||
|
||||
NSString *const kFIRIsMeasurementEnabled = @"IS_MEASUREMENT_ENABLED";
|
||||
NSString *const kFIRIsAnalyticsCollectionEnabled = @"FIREBASE_ANALYTICS_COLLECTION_ENABLED";
|
||||
NSString *const kFIRIsAnalyticsCollectionDeactivated = @"FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED";
|
||||
|
||||
NSString *const kFIRIsAnalyticsEnabled = @"IS_ANALYTICS_ENABLED";
|
||||
NSString *const kFIRIsSignInEnabled = @"IS_SIGNIN_ENABLED";
|
||||
|
||||
// Library version ID formatted like:
|
||||
// @"5" // Major version (one or more digits)
|
||||
// @"04" // Minor version (exactly 2 digits)
|
||||
// @"01" // Build number (exactly 2 digits)
|
||||
// @"000"; // Fixed "000"
|
||||
NSString *kFIRLibraryVersionID;
|
||||
|
||||
// Plist file name.
|
||||
NSString *const kServiceInfoFileName = @"GoogleService-Info";
|
||||
// Plist file type.
|
||||
NSString *const kServiceInfoFileType = @"plist";
|
||||
|
||||
// Exception raised from attempting to modify a FIROptions after it's been copied to a FIRApp.
|
||||
NSString *const kFIRExceptionBadModification =
|
||||
@"Attempted to modify options after it's set on FIRApp. Please modify all properties before "
|
||||
@"initializing FIRApp.";
|
||||
|
||||
@interface FIROptions ()
|
||||
|
||||
/**
|
||||
* This property maintains the actual configuration key-value pairs.
|
||||
*/
|
||||
@property(nonatomic, readwrite) NSMutableDictionary *optionsDictionary;
|
||||
|
||||
/**
|
||||
* Calls `analyticsOptionsDictionaryWithInfoDictionary:` using [NSBundle mainBundle].infoDictionary.
|
||||
* It combines analytics options from both the infoDictionary and the GoogleService-Info.plist.
|
||||
* Values which are present in the main plist override values from the GoogleService-Info.plist.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSDictionary *analyticsOptionsDictionary;
|
||||
|
||||
/**
|
||||
* Combination of analytics options from both the infoDictionary and the GoogleService-Info.plist.
|
||||
* Values which are present in the infoDictionary override values from the GoogleService-Info.plist.
|
||||
*/
|
||||
- (NSDictionary *)analyticsOptionsDictionaryWithInfoDictionary:(NSDictionary *)infoDictionary;
|
||||
|
||||
/**
|
||||
* Throw exception if editing is locked when attempting to modify an option.
|
||||
*/
|
||||
- (void)checkEditingLocked;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FIROptions {
|
||||
/// Backing variable for self.analyticsOptionsDictionary.
|
||||
NSDictionary *_analyticsOptionsDictionary;
|
||||
}
|
||||
|
||||
static FIROptions *sDefaultOptions = nil;
|
||||
static NSDictionary *sDefaultOptionsDictionary = nil;
|
||||
|
||||
#pragma mark - Public only for internal class methods
|
||||
|
||||
+ (FIROptions *)defaultOptions {
|
||||
if (sDefaultOptions != nil) {
|
||||
return sDefaultOptions;
|
||||
}
|
||||
|
||||
NSDictionary *defaultOptionsDictionary = [self defaultOptionsDictionary];
|
||||
if (defaultOptionsDictionary == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
sDefaultOptions = [[FIROptions alloc] initInternalWithOptionsDictionary:defaultOptionsDictionary];
|
||||
return sDefaultOptions;
|
||||
}
|
||||
|
||||
#pragma mark - Private class methods
|
||||
|
||||
+ (void)initialize {
|
||||
// Report FirebaseCore version for useragent string
|
||||
[FIRApp registerLibrary:@"fire-ios"
|
||||
withVersion:[NSString stringWithUTF8String:FIRCoreVersionString]];
|
||||
|
||||
NSDictionary<NSString *, id> *info = [[NSBundle mainBundle] infoDictionary];
|
||||
NSString *xcodeVersion = info[@"DTXcodeBuild"];
|
||||
NSString *sdkVersion = info[@"DTSDKBuild"];
|
||||
if (xcodeVersion) {
|
||||
[FIRApp registerLibrary:@"xcode" withVersion:xcodeVersion];
|
||||
}
|
||||
if (sdkVersion) {
|
||||
[FIRApp registerLibrary:@"apple-sdk" withVersion:sdkVersion];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSDictionary *)defaultOptionsDictionary {
|
||||
if (sDefaultOptionsDictionary != nil) {
|
||||
return sDefaultOptionsDictionary;
|
||||
}
|
||||
NSString *plistFilePath = [FIROptions plistFilePathWithName:kServiceInfoFileName];
|
||||
if (plistFilePath == nil) {
|
||||
return nil;
|
||||
}
|
||||
sDefaultOptionsDictionary = [NSDictionary dictionaryWithContentsOfFile:plistFilePath];
|
||||
if (sDefaultOptionsDictionary == nil) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000011",
|
||||
@"The configuration file is not a dictionary: "
|
||||
@"'%@.%@'.",
|
||||
kServiceInfoFileName, kServiceInfoFileType);
|
||||
}
|
||||
return sDefaultOptionsDictionary;
|
||||
}
|
||||
|
||||
// Returns the path of the plist file with a given file name.
|
||||
+ (NSString *)plistFilePathWithName:(NSString *)fileName {
|
||||
NSArray *bundles = [FIRBundleUtil relevantBundles];
|
||||
NSString *plistFilePath =
|
||||
[FIRBundleUtil optionsDictionaryPathWithResourceName:fileName
|
||||
andFileType:kServiceInfoFileType
|
||||
inBundles:bundles];
|
||||
if (plistFilePath == nil) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000012", @"Could not locate configuration file: '%@.%@'.",
|
||||
fileName, kServiceInfoFileType);
|
||||
}
|
||||
return plistFilePath;
|
||||
}
|
||||
|
||||
+ (void)resetDefaultOptions {
|
||||
sDefaultOptions = nil;
|
||||
sDefaultOptionsDictionary = nil;
|
||||
}
|
||||
|
||||
#pragma mark - Private instance methods
|
||||
|
||||
- (instancetype)initInternalWithOptionsDictionary:(NSDictionary *)optionsDictionary {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_optionsDictionary = [optionsDictionary mutableCopy];
|
||||
_usingOptionsFromDefaultPlist = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)copyWithZone:(NSZone *)zone {
|
||||
FIROptions *newOptions = [[[self class] allocWithZone:zone] init];
|
||||
if (newOptions) {
|
||||
newOptions.optionsDictionary = self.optionsDictionary;
|
||||
newOptions.deepLinkURLScheme = self.deepLinkURLScheme;
|
||||
newOptions.appGroupID = self.appGroupID;
|
||||
newOptions.editingLocked = self.isEditingLocked;
|
||||
newOptions.usingOptionsFromDefaultPlist = self.usingOptionsFromDefaultPlist;
|
||||
}
|
||||
return newOptions;
|
||||
}
|
||||
|
||||
#pragma mark - Public instance methods
|
||||
|
||||
- (instancetype)initWithContentsOfFile:(NSString *)plistPath {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (plistPath == nil) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000013", @"The plist file path is nil.");
|
||||
return nil;
|
||||
}
|
||||
_optionsDictionary = [[NSDictionary dictionaryWithContentsOfFile:plistPath] mutableCopy];
|
||||
if (_optionsDictionary == nil) {
|
||||
FIRLogError(kFIRLoggerCore, @"I-COR000014",
|
||||
@"The configuration file at %@ does not exist or "
|
||||
@"is not a well-formed plist file.",
|
||||
plistPath);
|
||||
return nil;
|
||||
}
|
||||
// TODO: Do we want to validate the dictionary here? It says we do that already in
|
||||
// the public header.
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithGoogleAppID:(NSString *)googleAppID GCMSenderID:(NSString *)GCMSenderID {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSMutableDictionary *mutableOptionsDict = [NSMutableDictionary dictionary];
|
||||
[mutableOptionsDict setValue:googleAppID forKey:kFIRGoogleAppID];
|
||||
[mutableOptionsDict setValue:GCMSenderID forKey:kFIRGCMSenderID];
|
||||
[mutableOptionsDict setValue:[[NSBundle mainBundle] bundleIdentifier] forKey:kFIRBundleID];
|
||||
self.optionsDictionary = mutableOptionsDict;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)APIKey {
|
||||
return self.optionsDictionary[kFIRAPIKey];
|
||||
}
|
||||
|
||||
- (void)checkEditingLocked {
|
||||
if (self.isEditingLocked) {
|
||||
[NSException raise:kFirebaseCoreErrorDomain format:kFIRExceptionBadModification];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setAPIKey:(NSString *)APIKey {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRAPIKey] = [APIKey copy];
|
||||
}
|
||||
|
||||
- (NSString *)clientID {
|
||||
return self.optionsDictionary[kFIRClientID];
|
||||
}
|
||||
|
||||
- (void)setClientID:(NSString *)clientID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRClientID] = [clientID copy];
|
||||
}
|
||||
|
||||
- (NSString *)trackingID {
|
||||
return self.optionsDictionary[kFIRTrackingID];
|
||||
}
|
||||
|
||||
- (void)setTrackingID:(NSString *)trackingID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRTrackingID] = [trackingID copy];
|
||||
}
|
||||
|
||||
- (NSString *)GCMSenderID {
|
||||
return self.optionsDictionary[kFIRGCMSenderID];
|
||||
}
|
||||
|
||||
- (void)setGCMSenderID:(NSString *)GCMSenderID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRGCMSenderID] = [GCMSenderID copy];
|
||||
}
|
||||
|
||||
- (NSString *)projectID {
|
||||
return self.optionsDictionary[kFIRProjectID];
|
||||
}
|
||||
|
||||
- (void)setProjectID:(NSString *)projectID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRProjectID] = [projectID copy];
|
||||
}
|
||||
|
||||
- (NSString *)androidClientID {
|
||||
return self.optionsDictionary[kFIRAndroidClientID];
|
||||
}
|
||||
|
||||
- (void)setAndroidClientID:(NSString *)androidClientID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRAndroidClientID] = [androidClientID copy];
|
||||
}
|
||||
|
||||
- (NSString *)googleAppID {
|
||||
return self.optionsDictionary[kFIRGoogleAppID];
|
||||
}
|
||||
|
||||
- (void)setGoogleAppID:(NSString *)googleAppID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRGoogleAppID] = [googleAppID copy];
|
||||
}
|
||||
|
||||
- (NSString *)libraryVersionID {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
// The unit tests are set up to catch anything that does not properly convert.
|
||||
NSString *version = [NSString stringWithUTF8String:FIRCoreVersionString];
|
||||
NSArray *components = [version componentsSeparatedByString:@"."];
|
||||
NSString *major = [components objectAtIndex:0];
|
||||
NSString *minor = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:1] intValue]];
|
||||
NSString *patch = [NSString stringWithFormat:@"%02d", [[components objectAtIndex:2] intValue]];
|
||||
kFIRLibraryVersionID = [NSString stringWithFormat:@"%@%@%@000", major, minor, patch];
|
||||
});
|
||||
return kFIRLibraryVersionID;
|
||||
}
|
||||
|
||||
- (void)setLibraryVersionID:(NSString *)libraryVersionID {
|
||||
_optionsDictionary[kFIRLibraryVersionID] = [libraryVersionID copy];
|
||||
}
|
||||
|
||||
- (NSString *)databaseURL {
|
||||
return self.optionsDictionary[kFIRDatabaseURL];
|
||||
}
|
||||
|
||||
- (void)setDatabaseURL:(NSString *)databaseURL {
|
||||
[self checkEditingLocked];
|
||||
|
||||
_optionsDictionary[kFIRDatabaseURL] = [databaseURL copy];
|
||||
}
|
||||
|
||||
- (NSString *)storageBucket {
|
||||
return self.optionsDictionary[kFIRStorageBucket];
|
||||
}
|
||||
|
||||
- (void)setStorageBucket:(NSString *)storageBucket {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRStorageBucket] = [storageBucket copy];
|
||||
}
|
||||
|
||||
- (void)setDeepLinkURLScheme:(NSString *)deepLinkURLScheme {
|
||||
[self checkEditingLocked];
|
||||
_deepLinkURLScheme = [deepLinkURLScheme copy];
|
||||
}
|
||||
|
||||
- (NSString *)bundleID {
|
||||
return self.optionsDictionary[kFIRBundleID];
|
||||
}
|
||||
|
||||
- (void)setBundleID:(NSString *)bundleID {
|
||||
[self checkEditingLocked];
|
||||
_optionsDictionary[kFIRBundleID] = [bundleID copy];
|
||||
}
|
||||
|
||||
- (void)setAppGroupID:(NSString *)appGroupID {
|
||||
[self checkEditingLocked];
|
||||
_appGroupID = [appGroupID copy];
|
||||
}
|
||||
|
||||
#pragma mark - Internal instance methods
|
||||
|
||||
- (NSDictionary *)analyticsOptionsDictionaryWithInfoDictionary:(NSDictionary *)infoDictionary {
|
||||
if (_analyticsOptionsDictionary == nil) {
|
||||
NSMutableDictionary *tempAnalyticsOptions = [[NSMutableDictionary alloc] init];
|
||||
NSArray *measurementKeys = @[
|
||||
kFIRIsMeasurementEnabled, kFIRIsAnalyticsCollectionEnabled,
|
||||
kFIRIsAnalyticsCollectionDeactivated
|
||||
];
|
||||
for (NSString *key in measurementKeys) {
|
||||
id value = infoDictionary[key] ?: self.optionsDictionary[key] ?: nil;
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
tempAnalyticsOptions[key] = value;
|
||||
}
|
||||
_analyticsOptionsDictionary = tempAnalyticsOptions;
|
||||
}
|
||||
return _analyticsOptionsDictionary;
|
||||
}
|
||||
|
||||
- (NSDictionary *)analyticsOptionsDictionary {
|
||||
return [self analyticsOptionsDictionaryWithInfoDictionary:[NSBundle mainBundle].infoDictionary];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not Measurement was enabled. Measurement is enabled unless explicitly disabled in
|
||||
* GoogleService-Info.plist. This uses the old plist flag IS_MEASUREMENT_ENABLED, which should still
|
||||
* be supported.
|
||||
*/
|
||||
- (BOOL)isMeasurementEnabled {
|
||||
if (self.isAnalyticsCollectionDeactivated) {
|
||||
return NO;
|
||||
}
|
||||
NSNumber *value = self.analyticsOptionsDictionary[kFIRIsMeasurementEnabled];
|
||||
if (value == nil) {
|
||||
// TODO: This could probably be cleaned up since FIROptions shouldn't know about FIRApp or have
|
||||
// to check if it's the default app. The FIROptions instance can't be modified after
|
||||
// `+configure` is called, so it's not a good place to copy it either in case the flag is
|
||||
// changed at runtime.
|
||||
|
||||
// If no values are set for Analytics, fall back to the global collection switch in FIRApp.
|
||||
// Analytics only supports the default FIRApp, so check that first.
|
||||
if (![FIRApp isDefaultAppConfigured]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Fall back to the default app's collection switch when the key is not in the dictionary.
|
||||
return [FIRApp defaultApp].isDataCollectionDefaultEnabled;
|
||||
}
|
||||
return [value boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)isAnalyticsCollectionExpicitlySet {
|
||||
// If it's de-activated, it classifies as explicity set. If not, it's not a good enough indication
|
||||
// that the developer wants FirebaseAnalytics enabled so continue checking.
|
||||
if (self.isAnalyticsCollectionDeactivated) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Check if the current Analytics flag is set.
|
||||
id collectionEnabledObject = self.analyticsOptionsDictionary[kFIRIsAnalyticsCollectionEnabled];
|
||||
if (collectionEnabledObject && [collectionEnabledObject isKindOfClass:[NSNumber class]]) {
|
||||
// It doesn't matter what the value is, it's explicitly set.
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Check if the old measurement flag is set.
|
||||
id measurementEnabledObject = self.analyticsOptionsDictionary[kFIRIsMeasurementEnabled];
|
||||
if (measurementEnabledObject && [measurementEnabledObject isKindOfClass:[NSNumber class]]) {
|
||||
// It doesn't matter what the value is, it's explicitly set.
|
||||
return YES;
|
||||
}
|
||||
|
||||
// No flags are set to explicitly enable or disable FirebaseAnalytics.
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isAnalyticsCollectionEnabled {
|
||||
if (self.isAnalyticsCollectionDeactivated) {
|
||||
return NO;
|
||||
}
|
||||
NSNumber *value = self.analyticsOptionsDictionary[kFIRIsAnalyticsCollectionEnabled];
|
||||
if (value == nil) {
|
||||
return self.isMeasurementEnabled; // Fall back to older plist flag.
|
||||
}
|
||||
return [value boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)isAnalyticsCollectionDeactivated {
|
||||
NSNumber *value = self.analyticsOptionsDictionary[kFIRIsAnalyticsCollectionDeactivated];
|
||||
if (value == nil) {
|
||||
return NO; // Analytics Collection is not deactivated when the key is not in the dictionary.
|
||||
}
|
||||
return [value boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)isAnalyticsEnabled {
|
||||
return [self.optionsDictionary[kFIRIsAnalyticsEnabled] boolValue];
|
||||
}
|
||||
|
||||
- (BOOL)isSignInEnabled {
|
||||
return [self.optionsDictionary[kFIRIsSignInEnabled] boolValue];
|
||||
}
|
||||
|
||||
@end
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef Firebase_VERSION
|
||||
#error "Firebase_VERSION is not defined: add -DFirebase_VERSION=... to the build invocation"
|
||||
#endif
|
||||
|
||||
#ifndef FIRCore_VERSION
|
||||
#error "FIRCore_VERSION is not defined: add -DFIRCore_VERSION=... to the build invocation"
|
||||
#endif
|
||||
|
||||
// The following two macros supply the incantation so that the C
|
||||
// preprocessor does not try to parse the version as a floating
|
||||
// point number. See
|
||||
// https://www.guyrutenberg.com/2008/12/20/expanding-macros-into-string-constants-in-c/
|
||||
#define STR(x) STR_EXPAND(x)
|
||||
#define STR_EXPAND(x) #x
|
||||
|
||||
const char *const FIRVersionString = (const char *const)STR(Firebase_VERSION);
|
||||
const char *const FIRCoreVersionString = (const char *const)STR(FIRCore_VERSION);
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// Values stored in analyticsEnabledState. Never alter these constants since they must match with
|
||||
/// values persisted to disk.
|
||||
typedef NS_ENUM(int64_t, FIRAnalyticsEnabledState) {
|
||||
// 0 is the default value for keys not found stored in persisted config, so it cannot represent
|
||||
// kFIRAnalyticsEnabledStateSetNo. It must represent kFIRAnalyticsEnabledStateNotSet.
|
||||
kFIRAnalyticsEnabledStateNotSet = 0,
|
||||
kFIRAnalyticsEnabledStateSetYes = 1,
|
||||
kFIRAnalyticsEnabledStateSetNo = 2,
|
||||
};
|
||||
|
||||
/// The user defaults key for the persisted measurementEnabledState value. FIRAPersistedConfig reads
|
||||
/// measurementEnabledState using this same key.
|
||||
static NSString *const kFIRAPersistedConfigMeasurementEnabledStateKey =
|
||||
@"/google/measurement/measurement_enabled_state";
|
||||
|
||||
static NSString *const kFIRAnalyticsConfigurationSetEnabledNotification =
|
||||
@"FIRAnalyticsConfigurationSetEnabledNotification";
|
||||
static NSString *const kFIRAnalyticsConfigurationSetMinimumSessionIntervalNotification =
|
||||
@"FIRAnalyticsConfigurationSetMinimumSessionIntervalNotification";
|
||||
static NSString *const kFIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification =
|
||||
@"FIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification";
|
||||
|
||||
@interface FIRAnalyticsConfiguration : NSObject
|
||||
|
||||
/// Returns the shared instance of FIRAnalyticsConfiguration.
|
||||
+ (FIRAnalyticsConfiguration *)sharedInstance;
|
||||
|
||||
// Sets whether analytics collection is enabled for this app on this device. This setting is
|
||||
// persisted across app sessions. By default it is enabled.
|
||||
- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled;
|
||||
|
||||
/// Sets whether analytics collection is enabled for this app on this device, and a flag to persist
|
||||
/// the value or not. The setting should not be persisted if being set by the global data collection
|
||||
/// flag.
|
||||
- (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled
|
||||
persistSetting:(BOOL)shouldPersist;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// TODO: Remove this once Auth moves over to Core's instance registration system.
|
||||
/** @class FIRAppAssociationRegistration
|
||||
@brief Manages object associations as a singleton-dependent: At most one object is
|
||||
registered for any given host/key pair, and the object shall be created on-the-fly when
|
||||
asked for.
|
||||
*/
|
||||
@interface FIRAppAssociationRegistration<ObjectType> : NSObject
|
||||
|
||||
/** @fn registeredObjectWithHost:key:creationBlock:
|
||||
@brief Retrieves the registered object with a particular host and key.
|
||||
@param host The host object.
|
||||
@param key The key to specify the registered object on the host.
|
||||
@param creationBlock The block to return the object to be registered if not already.
|
||||
The block is executed immediately before this method returns if it is executed at all.
|
||||
It can also be executed multiple times across different method invocations if previous
|
||||
execution of the block returns @c nil.
|
||||
@return The registered object for the host/key pair, or @c nil if no object is registered
|
||||
and @c creationBlock returns @c nil.
|
||||
@remarks The method is thread-safe but non-reentrant in the sense that attempting to call this
|
||||
method again within the @c creationBlock with the same host/key pair raises an exception.
|
||||
The registered object is retained by the host.
|
||||
*/
|
||||
+ (nullable ObjectType)registeredObjectWithHost:(id)host
|
||||
key:(NSString *)key
|
||||
creationBlock:(ObjectType _Nullable (^)(void))creationBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <FirebaseCore/FIRApp.h>
|
||||
#import <FirebaseCore/FIRErrors.h>
|
||||
|
||||
@class FIRComponentContainer;
|
||||
@protocol FIRLibrary;
|
||||
|
||||
/**
|
||||
* The internal interface to FIRApp. This is meant for first-party integrators, who need to receive
|
||||
* FIRApp notifications, log info about the success or failure of their configuration, and access
|
||||
* other internal functionality of FIRApp.
|
||||
*
|
||||
* TODO(b/28296561): Restructure this header.
|
||||
*/
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, FIRConfigType) {
|
||||
FIRConfigTypeCore = 1,
|
||||
FIRConfigTypeSDK = 2,
|
||||
};
|
||||
|
||||
extern NSString *const kFIRDefaultAppName;
|
||||
extern NSString *const kFIRAppReadyToConfigureSDKNotification;
|
||||
extern NSString *const kFIRAppDeleteNotification;
|
||||
extern NSString *const kFIRAppIsDefaultAppKey;
|
||||
extern NSString *const kFIRAppNameKey;
|
||||
extern NSString *const kFIRGoogleAppIDKey;
|
||||
|
||||
/**
|
||||
* The format string for the User Defaults key used for storing the data collection enabled flag.
|
||||
* This includes formatting to append the Firebase App's name.
|
||||
*/
|
||||
extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
|
||||
|
||||
/**
|
||||
* The plist key used for storing the data collection enabled flag.
|
||||
*/
|
||||
extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;
|
||||
|
||||
/**
|
||||
* A notification fired containing diagnostic information when SDK errors occur.
|
||||
*/
|
||||
extern NSString *const kFIRAppDiagnosticsNotification;
|
||||
|
||||
/** @var FIRAuthStateDidChangeInternalNotification
|
||||
@brief The name of the @c NSNotificationCenter notification which is posted when the auth state
|
||||
changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
|
||||
the notification is a dictionary possibly containing the key:
|
||||
@c FIRAuthStateDidChangeInternalNotificationTokenKey (the new access token.) If it does not
|
||||
contain this key it indicates a sign-out event took place.
|
||||
*/
|
||||
extern NSString *const FIRAuthStateDidChangeInternalNotification;
|
||||
|
||||
/** @var FIRAuthStateDidChangeInternalNotificationTokenKey
|
||||
@brief A key present in the dictionary object parameter of the
|
||||
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
|
||||
key will contain the new access token.
|
||||
*/
|
||||
extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
|
||||
|
||||
/** @var FIRAuthStateDidChangeInternalNotificationAppKey
|
||||
@brief A key present in the dictionary object parameter of the
|
||||
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
|
||||
key will contain the FIRApp associated with the auth instance.
|
||||
*/
|
||||
extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
|
||||
|
||||
/** @var FIRAuthStateDidChangeInternalNotificationUIDKey
|
||||
@brief A key present in the dictionary object parameter of the
|
||||
@c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
|
||||
key will contain the new user's UID (or nil if there is no longer a user signed in).
|
||||
*/
|
||||
extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
|
||||
|
||||
@interface FIRApp ()
|
||||
|
||||
/**
|
||||
* A flag indicating if this is the default app (has the default app name).
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isDefaultApp;
|
||||
|
||||
/*
|
||||
* The container of interop SDKs for this app.
|
||||
*/
|
||||
@property(nonatomic) FIRComponentContainer *container;
|
||||
|
||||
/**
|
||||
* Creates an error for failing to configure a subspec service. This method is called by each
|
||||
* FIRApp notification listener.
|
||||
*/
|
||||
+ (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain
|
||||
errorCode:(FIRErrorCode)code
|
||||
service:(NSString *)service
|
||||
reason:(NSString *)reason;
|
||||
/**
|
||||
* Checks if the default app is configured without trying to configure it.
|
||||
*/
|
||||
+ (BOOL)isDefaultAppConfigured;
|
||||
|
||||
/**
|
||||
* Registers a given third-party library with the given version number to be reported for
|
||||
* analytics.
|
||||
*
|
||||
* @param name Name of the library.
|
||||
* @param version Version of the library.
|
||||
*/
|
||||
+ (void)registerLibrary:(nonnull NSString *)name withVersion:(nonnull NSString *)version;
|
||||
|
||||
/**
|
||||
* Registers a given internal library with the given version number to be reported for
|
||||
* analytics.
|
||||
*
|
||||
* @param library Optional parameter for component registration.
|
||||
* @param name Name of the library.
|
||||
* @param version Version of the library.
|
||||
*/
|
||||
+ (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
|
||||
withName:(nonnull NSString *)name
|
||||
withVersion:(nonnull NSString *)version;
|
||||
|
||||
/**
|
||||
* A concatenated string representing all the third-party libraries and version numbers.
|
||||
*/
|
||||
+ (NSString *)firebaseUserAgent;
|
||||
|
||||
/**
|
||||
* Used by each SDK to send logs about SDK configuration status to Clearcut.
|
||||
*
|
||||
* @note This API is a no-op, please remove calls to it.
|
||||
*/
|
||||
- (void)sendLogsWithServiceName:(NSString *)serviceName
|
||||
version:(NSString *)version
|
||||
error:(NSError *)error;
|
||||
|
||||
/**
|
||||
* Can be used by the unit tests in eack SDK to reset FIRApp. This method is thread unsafe.
|
||||
*/
|
||||
+ (void)resetApps;
|
||||
|
||||
/**
|
||||
* Can be used by the unit tests in each SDK to set customized options.
|
||||
*/
|
||||
- (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* This class provides utilities for accessing resources in bundles.
|
||||
*/
|
||||
@interface FIRBundleUtil : NSObject
|
||||
|
||||
/**
|
||||
* Finds all relevant bundles, starting with [NSBundle mainBundle].
|
||||
*/
|
||||
+ (NSArray *)relevantBundles;
|
||||
|
||||
/**
|
||||
* Reads the options dictionary from one of the provided bundles.
|
||||
*
|
||||
* @param resourceName The resource name, e.g. @"GoogleService-Info".
|
||||
* @param fileType The file type (extension), e.g. @"plist".
|
||||
* @param bundles The bundles to expect, in priority order. See also
|
||||
* +[FIRBundleUtil relevantBundles].
|
||||
*/
|
||||
+ (NSString *)optionsDictionaryPathWithResourceName:(NSString *)resourceName
|
||||
andFileType:(NSString *)fileType
|
||||
inBundles:(NSArray *)bundles;
|
||||
|
||||
/**
|
||||
* Finds URL schemes defined in all relevant bundles, starting with those from
|
||||
* [NSBundle mainBundle].
|
||||
*/
|
||||
+ (NSArray *)relevantURLSchemes;
|
||||
|
||||
/**
|
||||
* Checks if any of the given bundles have a matching bundle identifier prefix (removing extension
|
||||
* suffixes).
|
||||
*/
|
||||
+ (BOOL)hasBundleIdentifierPrefix:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FIRApp;
|
||||
@class FIRComponentContainer;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Provides a system to clean up cached instances returned from the component system.
|
||||
NS_SWIFT_NAME(ComponentLifecycleMaintainer)
|
||||
@protocol FIRComponentLifecycleMaintainer
|
||||
/// The associated app will be deleted, clean up any resources as they are about to be deallocated.
|
||||
- (void)appWillBeDeleted:(FIRApp *)app;
|
||||
@end
|
||||
|
||||
typedef _Nullable id (^FIRComponentCreationBlock)(FIRComponentContainer *container,
|
||||
BOOL *isCacheable)
|
||||
NS_SWIFT_NAME(ComponentCreationBlock);
|
||||
|
||||
@class FIRDependency;
|
||||
|
||||
/// Describes the timing of instantiation. Note: new components should default to lazy unless there
|
||||
/// is a strong reason to be eager.
|
||||
typedef NS_ENUM(NSInteger, FIRInstantiationTiming) {
|
||||
FIRInstantiationTimingLazy,
|
||||
FIRInstantiationTimingAlwaysEager,
|
||||
FIRInstantiationTimingEagerInDefaultApp
|
||||
} NS_SWIFT_NAME(InstantiationTiming);
|
||||
|
||||
/// A component that can be used from other Firebase SDKs.
|
||||
NS_SWIFT_NAME(Component)
|
||||
@interface FIRComponent : NSObject
|
||||
|
||||
/// The protocol describing functionality provided from the Component.
|
||||
@property(nonatomic, strong, readonly) Protocol *protocol;
|
||||
|
||||
/// The timing of instantiation.
|
||||
@property(nonatomic, readonly) FIRInstantiationTiming instantiationTiming;
|
||||
|
||||
/// An array of dependencies for the component.
|
||||
@property(nonatomic, copy, readonly) NSArray<FIRDependency *> *dependencies;
|
||||
|
||||
/// A block to instantiate an instance of the component with the appropriate dependencies.
|
||||
@property(nonatomic, copy, readonly) FIRComponentCreationBlock creationBlock;
|
||||
|
||||
// There's an issue with long NS_SWIFT_NAMES that causes compilation to fail, disable clang-format
|
||||
// for the next two methods.
|
||||
// clang-format off
|
||||
|
||||
/// Creates a component with no dependencies that will be lazily initialized.
|
||||
+ (instancetype)componentWithProtocol:(Protocol *)protocol
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock
|
||||
NS_SWIFT_NAME(init(_:creationBlock:));
|
||||
|
||||
/// Creates a component to be registered with the component container.
|
||||
///
|
||||
/// @param protocol - The protocol describing functionality provided by the component.
|
||||
/// @param instantiationTiming - When the component should be initialized. Use .lazy unless there's
|
||||
/// a good reason to be instantiated earlier.
|
||||
/// @param dependencies - Any dependencies the `implementingClass` has, optional or required.
|
||||
/// @param creationBlock - A block to instantiate the component with a container, and if
|
||||
/// @return A component that can be registered with the component container.
|
||||
+ (instancetype)componentWithProtocol:(Protocol *)protocol
|
||||
instantiationTiming:(FIRInstantiationTiming)instantiationTiming
|
||||
dependencies:(NSArray<FIRDependency *> *)dependencies
|
||||
creationBlock:(FIRComponentCreationBlock)creationBlock
|
||||
NS_SWIFT_NAME(init(_:instantiationTiming:dependencies:creationBlock:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
/// Unavailable.
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FIRComponentType.h"
|
||||
#import "FIRLibrary.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// A type-safe macro to retrieve a component from a container. This should be used to retrieve
|
||||
/// components instead of using the container directly.
|
||||
#define FIR_COMPONENT(type, container) \
|
||||
[FIRComponentType<id<type>> instanceForProtocol:@protocol(type) inContainer:container]
|
||||
|
||||
@class FIRApp;
|
||||
|
||||
/// A container that holds different components that are registered via the
|
||||
/// `registerAsComponentRegistrant:` call. These classes should conform to `FIRComponentRegistrant`
|
||||
/// in order to properly register components for Core.
|
||||
NS_SWIFT_NAME(FirebaseComponentContainer)
|
||||
@interface FIRComponentContainer : NSObject
|
||||
|
||||
/// A weak reference to the app that an instance of the container belongs to.
|
||||
@property(nonatomic, weak, readonly) FIRApp *app;
|
||||
|
||||
/// Unavailable. Use the `container` property on `FIRApp`.
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FIRComponent.h"
|
||||
#import "FIRComponentContainer.h"
|
||||
|
||||
@class FIRApp;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FIRComponentContainer (Private)
|
||||
|
||||
/// Initializes a contain for a given app. This should only be called by the app itself.
|
||||
- (instancetype)initWithApp:(FIRApp *)app;
|
||||
|
||||
/// Retrieves an instance that conforms to the specified protocol. This will return `nil` if the
|
||||
/// protocol wasn't registered, or if the instance couldn't instantiate for the provided app.
|
||||
- (nullable id)instanceForProtocol:(Protocol *)protocol NS_SWIFT_NAME(instance(for:));
|
||||
|
||||
/// Remove all of the cached instances stored and allow them to clean up after themselves.
|
||||
- (void)removeAllCachedInstances;
|
||||
|
||||
/// Register a class to provide components for the interoperability system. The class should conform
|
||||
/// to `FIRComponentRegistrant` and provide an array of `FIRComponent` objects.
|
||||
+ (void)registerAsComponentRegistrant:(Class<FIRLibrary>)klass;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FIRComponentContainer;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Do not use directly. A placeholder type in order to provide a macro that will warn users of
|
||||
/// mis-matched protocols.
|
||||
NS_SWIFT_NAME(ComponentType)
|
||||
@interface FIRComponentType<__covariant T> : NSObject
|
||||
|
||||
/// Do not use directly. A factory method to retrieve an instance that provides a specific
|
||||
/// functionality.
|
||||
+ (T)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FIRConfiguration.h"
|
||||
|
||||
@class FIRAnalyticsConfiguration;
|
||||
|
||||
@interface FIRConfiguration ()
|
||||
|
||||
/**
|
||||
* The configuration class for Firebase Analytics. This should be removed once the logic for
|
||||
* enabling and disabling Analytics is moved to Analytics.
|
||||
*/
|
||||
@property(nonatomic, readwrite) FIRAnalyticsConfiguration *analyticsConfiguration;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FIRDiagnosticsData;
|
||||
@class FIROptions;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Connects FIRCore with the CoreDiagnostics library. */
|
||||
@interface FIRCoreDiagnosticsConnector : NSObject
|
||||
|
||||
/** Logs FirebaseCore related data.
|
||||
*
|
||||
* @param options The options object containing data to log.
|
||||
*/
|
||||
+ (void)logCoreTelemetryWithOptions:(FIROptions *)options;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// A dependency on a specific protocol's functionality.
|
||||
NS_SWIFT_NAME(Dependency)
|
||||
@interface FIRDependency : NSObject
|
||||
|
||||
/// The protocol describing functionality being depended on.
|
||||
@property(nonatomic, strong, readonly) Protocol *protocol;
|
||||
|
||||
/// A flag to specify if the dependency is required or not.
|
||||
@property(nonatomic, readonly) BOOL isRequired;
|
||||
|
||||
/// Initializes a dependency that is required. Calls `initWithProtocol:isRequired` with `YES` for
|
||||
/// the required parameter.
|
||||
/// Creates a required dependency on the specified protocol's functionality.
|
||||
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol;
|
||||
|
||||
/// Creates a dependency on the specified protocol's functionality and specify if it's required for
|
||||
/// the class's functionality.
|
||||
+ (instancetype)dependencyWithProtocol:(Protocol *)protocol isRequired:(BOOL)required;
|
||||
|
||||
/// Use `dependencyWithProtocol:isRequired:` instead.
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2019 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Implements the FIRCoreDiagnosticsData protocol to log diagnostics data. */
|
||||
@interface FIRDiagnosticsData : NSObject <FIRCoreDiagnosticsData>
|
||||
|
||||
/** Inserts values into the diagnosticObjects dictionary if the value isn't nil.
|
||||
*
|
||||
* @param value The value to insert if it's not nil.
|
||||
* @param key The key to associate it with.
|
||||
*/
|
||||
- (void)insertValue:(nullable id)value forKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** Error codes in Firebase error domain. */
|
||||
typedef NS_ENUM(NSInteger, FIRErrorCode) {
|
||||
/**
|
||||
* Unknown error.
|
||||
*/
|
||||
FIRErrorCodeUnknown = 0,
|
||||
/**
|
||||
* Loading data from the GoogleService-Info.plist file failed. This is a fatal error and should
|
||||
* not be ignored. Further calls to the API will fail and/or possibly cause crashes.
|
||||
*/
|
||||
FIRErrorCodeInvalidPlistFile = -100,
|
||||
|
||||
/**
|
||||
* Validating the Google App ID format failed.
|
||||
*/
|
||||
FIRErrorCodeInvalidAppID = -101,
|
||||
|
||||
/**
|
||||
* Error code for failing to configure a specific service.
|
||||
*/
|
||||
FIRErrorCodeConfigFailed = -114,
|
||||
};
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#include "FIRErrorCode.h"
|
||||
|
||||
extern NSString *const kFirebaseErrorDomain;
|
||||
extern NSString *const kFirebaseConfigErrorDomain;
|
||||
extern NSString *const kFirebaseCoreErrorDomain;
|
||||
extern NSString *const kFirebasePerfErrorDomain;
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2018 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FIRLibrary_h
|
||||
#define FIRLibrary_h
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "FIRComponent.h"
|
||||
|
||||
@class FIRApp;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Provide an interface to register a library for userAgent logging and availability to others.
|
||||
NS_SWIFT_NAME(Library)
|
||||
@protocol FIRLibrary
|
||||
|
||||
/// Returns one or more FIRComponents that will be registered in
|
||||
/// FIRApp and participate in dependency resolution and injection.
|
||||
+ (NSArray<FIRComponent *> *)componentsToRegister;
|
||||
|
||||
@optional
|
||||
/// Implement this method if the library needs notifications for lifecycle events. This method is
|
||||
/// called when the developer calls `FirebaseApp.configure()`.
|
||||
+ (void)configureWithApp:(FIRApp *)app;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif /* FIRLibrary_h */
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <FirebaseCore/FIRLoggerLevel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* The Firebase services used in Firebase logger.
|
||||
*/
|
||||
typedef NSString *const FIRLoggerService;
|
||||
|
||||
extern FIRLoggerService kFIRLoggerABTesting;
|
||||
extern FIRLoggerService kFIRLoggerAdMob;
|
||||
extern FIRLoggerService kFIRLoggerAnalytics;
|
||||
extern FIRLoggerService kFIRLoggerAuth;
|
||||
extern FIRLoggerService kFIRLoggerCrash;
|
||||
extern FIRLoggerService kFIRLoggerCore;
|
||||
extern FIRLoggerService kFIRLoggerMLKit;
|
||||
extern FIRLoggerService kFIRLoggerPerf;
|
||||
extern FIRLoggerService kFIRLoggerRemoteConfig;
|
||||
|
||||
/**
|
||||
* The key used to store the logger's error count.
|
||||
*/
|
||||
extern NSString *const kFIRLoggerErrorCountKey;
|
||||
|
||||
/**
|
||||
* The key used to store the logger's warning count.
|
||||
*/
|
||||
extern NSString *const kFIRLoggerWarningCountKey;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* Enables or disables Analytics debug mode.
|
||||
* If set to YES, the logging level for Analytics will be set to FIRLoggerLevelDebug.
|
||||
* Enabling the debug mode has no effect if the app is running from App Store.
|
||||
* (required) analytics debug mode flag.
|
||||
*/
|
||||
void FIRSetAnalyticsDebugMode(BOOL analyticsDebugMode);
|
||||
|
||||
/**
|
||||
* Changes the default logging level of FIRLoggerLevelNotice to a user-specified level.
|
||||
* The default level cannot be set above FIRLoggerLevelNotice if the app is running from App Store.
|
||||
* (required) log level (one of the FIRLoggerLevel enum values).
|
||||
*/
|
||||
void FIRSetLoggerLevel(FIRLoggerLevel loggerLevel);
|
||||
|
||||
/**
|
||||
* Checks if the specified logger level is loggable given the current settings.
|
||||
* (required) log level (one of the FIRLoggerLevel enum values).
|
||||
* (required) whether or not this function is called from the Analytics component.
|
||||
*/
|
||||
BOOL FIRIsLoggableLevel(FIRLoggerLevel loggerLevel, BOOL analyticsComponent);
|
||||
|
||||
/**
|
||||
* Logs a message to the Xcode console and the device log. If running from AppStore, will
|
||||
* not log any messages with a level higher than FIRLoggerLevelNotice to avoid log spamming.
|
||||
* (required) log level (one of the FIRLoggerLevel enum values).
|
||||
* (required) service name of type FIRLoggerService.
|
||||
* (required) message code starting with "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) variable arguments list obtained from calling va_start, used when message is a format
|
||||
* string.
|
||||
*/
|
||||
extern void FIRLogBasic(FIRLoggerLevel level,
|
||||
FIRLoggerService service,
|
||||
NSString *messageCode,
|
||||
NSString *message,
|
||||
// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
|
||||
// See: http://stackoverflow.com/q/29095469
|
||||
#if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX
|
||||
va_list args_ptr
|
||||
#else
|
||||
va_list _Nullable args_ptr
|
||||
#endif
|
||||
);
|
||||
|
||||
/**
|
||||
* The following functions accept the following parameters in order:
|
||||
* (required) service name of type FIRLoggerService.
|
||||
* (required) message code starting from "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* See go/firebase-log-proposal for details.
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) the list of arguments to substitute into the format string.
|
||||
* Example usage:
|
||||
* FIRLogError(kFIRLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name);
|
||||
*/
|
||||
extern void FIRLogError(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
|
||||
NS_FORMAT_FUNCTION(3, 4);
|
||||
extern void FIRLogWarning(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
|
||||
NS_FORMAT_FUNCTION(3, 4);
|
||||
extern void FIRLogNotice(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
|
||||
NS_FORMAT_FUNCTION(3, 4);
|
||||
extern void FIRLogInfo(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
|
||||
NS_FORMAT_FUNCTION(3, 4);
|
||||
extern void FIRLogDebug(FIRLoggerService service, NSString *messageCode, NSString *message, ...)
|
||||
NS_FORMAT_FUNCTION(3, 4);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
@interface FIRLoggerWrapper : NSObject
|
||||
|
||||
/**
|
||||
* Objective-C wrapper for FIRLogBasic to allow weak linking to FIRLogger
|
||||
* (required) log level (one of the FIRLoggerLevel enum values).
|
||||
* (required) service name of type FIRLoggerService.
|
||||
* (required) message code starting with "I-" which means iOS, followed by a capitalized
|
||||
* three-character service identifier and a six digit integer message ID that is unique
|
||||
* within the service.
|
||||
* An example of the message code is @"I-COR000001".
|
||||
* (required) message string which can be a format string.
|
||||
* (optional) variable arguments list obtained from calling va_start, used when message is a format
|
||||
* string.
|
||||
*/
|
||||
|
||||
+ (void)logWithLevel:(FIRLoggerLevel)level
|
||||
withService:(FIRLoggerService)service
|
||||
withCode:(NSString *)messageCode
|
||||
withMessage:(NSString *)message
|
||||
withArgs:(va_list)args;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <FirebaseCore/FIROptions.h>
|
||||
|
||||
/**
|
||||
* Keys for the strings in the plist file.
|
||||
*/
|
||||
extern NSString *const kFIRAPIKey;
|
||||
extern NSString *const kFIRTrackingID;
|
||||
extern NSString *const kFIRGoogleAppID;
|
||||
extern NSString *const kFIRClientID;
|
||||
extern NSString *const kFIRGCMSenderID;
|
||||
extern NSString *const kFIRAndroidClientID;
|
||||
extern NSString *const kFIRDatabaseURL;
|
||||
extern NSString *const kFIRStorageBucket;
|
||||
extern NSString *const kFIRBundleID;
|
||||
extern NSString *const kFIRProjectID;
|
||||
|
||||
/**
|
||||
* Keys for the plist file name
|
||||
*/
|
||||
extern NSString *const kServiceInfoFileName;
|
||||
|
||||
extern NSString *const kServiceInfoFileType;
|
||||
|
||||
/**
|
||||
* This header file exposes the initialization of FIROptions to internal use.
|
||||
*/
|
||||
@interface FIROptions ()
|
||||
|
||||
/**
|
||||
* resetDefaultOptions and initInternalWithOptionsDictionary: are exposed only for unit tests.
|
||||
*/
|
||||
+ (void)resetDefaultOptions;
|
||||
|
||||
/**
|
||||
* Initializes the options with dictionary. The above strings are the keys of the dictionary.
|
||||
* This is the designated initializer.
|
||||
*/
|
||||
- (instancetype)initInternalWithOptionsDictionary:(NSDictionary *)serviceInfoDictionary;
|
||||
|
||||
/**
|
||||
* defaultOptions and defaultOptionsDictionary are exposed in order to be used in FIRApp and
|
||||
* other first party services.
|
||||
*/
|
||||
+ (FIROptions *)defaultOptions;
|
||||
|
||||
+ (NSDictionary *)defaultOptionsDictionary;
|
||||
|
||||
/**
|
||||
* Indicates whether or not Analytics collection was explicitly enabled via a plist flag or at
|
||||
* runtime.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isAnalyticsCollectionExpicitlySet;
|
||||
|
||||
/**
|
||||
* Whether or not Analytics Collection was enabled. Analytics Collection is enabled unless
|
||||
* explicitly disabled in GoogleService-Info.plist.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isAnalyticsCollectionEnabled;
|
||||
|
||||
/**
|
||||
* Whether or not Analytics Collection was completely disabled. If YES, then
|
||||
* isAnalyticsCollectionEnabled will be NO.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isAnalyticsCollectionDeactivated;
|
||||
|
||||
/**
|
||||
* The version ID of the client library, e.g. @"1100000".
|
||||
*/
|
||||
@property(nonatomic, readonly, copy) NSString *libraryVersionID;
|
||||
|
||||
/**
|
||||
* The flag indicating whether this object was constructed with the values in the default plist
|
||||
* file.
|
||||
*/
|
||||
@property(nonatomic) BOOL usingOptionsFromDefaultPlist;
|
||||
|
||||
/**
|
||||
* Whether or not Measurement was enabled. Measurement is enabled unless explicitly disabled in
|
||||
* GoogleService-Info.plist.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isMeasurementEnabled;
|
||||
|
||||
/**
|
||||
* Whether or not Analytics was enabled in the developer console.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isAnalyticsEnabled;
|
||||
|
||||
/**
|
||||
* Whether or not SignIn was enabled in the developer console.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isSignInEnabled;
|
||||
|
||||
/**
|
||||
* Whether or not editing is locked. This should occur after FIROptions has been set on a FIRApp.
|
||||
*/
|
||||
@property(nonatomic, getter=isEditingLocked) BOOL editingLocked;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/** The version of the Firebase SDK. */
|
||||
FOUNDATION_EXPORT const char *const FIRVersionString;
|
||||
|
||||
/** The version of the FirebaseCore Component. */
|
||||
FOUNDATION_EXPORT const char *const FIRCoreVersionString;
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class FIROptions;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** A block that takes a BOOL and has no return value. */
|
||||
typedef void (^FIRAppVoidBoolCallback)(BOOL success) NS_SWIFT_NAME(FirebaseAppVoidBoolCallback);
|
||||
|
||||
/**
|
||||
* The entry point of Firebase SDKs.
|
||||
*
|
||||
* Initialize and configure FIRApp using +[FIRApp configure]
|
||||
* or other customized ways as shown below.
|
||||
*
|
||||
* The logging system has two modes: default mode and debug mode. In default mode, only logs with
|
||||
* log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent
|
||||
* to device. The log levels that Firebase uses are consistent with the ASL log levels.
|
||||
*
|
||||
* Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this
|
||||
* argument in the application's Xcode scheme. When debug mode is enabled via -FIRDebugEnabled,
|
||||
* further executions of the application will also be in debug mode. In order to return to default
|
||||
* mode, you must explicitly disable the debug mode with the application argument -FIRDebugDisabled.
|
||||
*
|
||||
* It is also possible to change the default logging level in code by calling setLoggerLevel: on
|
||||
* the FIRConfiguration interface.
|
||||
*/
|
||||
NS_SWIFT_NAME(FirebaseApp)
|
||||
@interface FIRApp : NSObject
|
||||
|
||||
/**
|
||||
* Configures a default Firebase app. Raises an exception if any configuration step fails. The
|
||||
* default app is named "__FIRAPP_DEFAULT". This method should be called after the app is launched
|
||||
* and before using Firebase services. This method is thread safe and contains synchronous file I/O
|
||||
* (reading GoogleService-Info.plist from disk).
|
||||
*/
|
||||
+ (void)configure;
|
||||
|
||||
/**
|
||||
* Configures the default Firebase app with the provided options. The default app is named
|
||||
* "__FIRAPP_DEFAULT". Raises an exception if any configuration step fails. This method is thread
|
||||
* safe.
|
||||
*
|
||||
* @param options The Firebase application options used to configure the service.
|
||||
*/
|
||||
+ (void)configureWithOptions:(FIROptions *)options NS_SWIFT_NAME(configure(options:));
|
||||
|
||||
/**
|
||||
* Configures a Firebase app with the given name and options. Raises an exception if any
|
||||
* configuration step fails. This method is thread safe.
|
||||
*
|
||||
* @param name The application's name given by the developer. The name should should only contain
|
||||
Letters, Numbers and Underscore.
|
||||
* @param options The Firebase application options used to configure the services.
|
||||
*/
|
||||
// clang-format off
|
||||
+ (void)configureWithName:(NSString *)name
|
||||
options:(FIROptions *)options NS_SWIFT_NAME(configure(name:options:));
|
||||
// clang-format on
|
||||
|
||||
/**
|
||||
* Returns the default app, or nil if the default app does not exist.
|
||||
*/
|
||||
+ (nullable FIRApp *)defaultApp NS_SWIFT_NAME(app());
|
||||
|
||||
/**
|
||||
* Returns a previously created FIRApp instance with the given name, or nil if no such app exists.
|
||||
* This method is thread safe.
|
||||
*/
|
||||
+ (nullable FIRApp *)appNamed:(NSString *)name NS_SWIFT_NAME(app(name:));
|
||||
|
||||
/**
|
||||
* Returns the set of all extant FIRApp instances, or nil if there are no FIRApp instances. This
|
||||
* method is thread safe.
|
||||
*/
|
||||
@property(class, readonly, nullable) NSDictionary<NSString *, FIRApp *> *allApps;
|
||||
|
||||
/**
|
||||
* Cleans up the current FIRApp, freeing associated data and returning its name to the pool for
|
||||
* future use. This method is thread safe.
|
||||
*/
|
||||
- (void)deleteApp:(FIRAppVoidBoolCallback)completion;
|
||||
|
||||
/**
|
||||
* FIRApp instances should not be initialized directly. Call +[FIRApp configure],
|
||||
* +[FIRApp configureWithOptions:], or +[FIRApp configureWithNames:options:] directly.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Gets the name of this app.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) NSString *name;
|
||||
|
||||
/**
|
||||
* Gets a copy of the options for this app. These are non-modifiable.
|
||||
*/
|
||||
@property(nonatomic, copy, readonly) FIROptions *options;
|
||||
|
||||
/**
|
||||
* Gets or sets whether automatic data collection is enabled for all products. Defaults to `YES`
|
||||
* unless `FirebaseDataCollectionDefaultEnabled` is set to `NO` in your app's Info.plist. This value
|
||||
* is persisted across runs of the app so that it can be set once when users have consented to
|
||||
* collection.
|
||||
*/
|
||||
@property(nonatomic, readwrite, getter=isDataCollectionDefaultEnabled)
|
||||
BOOL dataCollectionDefaultEnabled;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import <FirebaseCore/FIRLoggerLevel.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* This interface provides global level properties that the developer can tweak.
|
||||
*/
|
||||
NS_SWIFT_NAME(FirebaseConfiguration)
|
||||
@interface FIRConfiguration : NSObject
|
||||
|
||||
/** Returns the shared configuration object. */
|
||||
@property(class, nonatomic, readonly) FIRConfiguration *sharedInstance NS_SWIFT_NAME(shared);
|
||||
|
||||
/**
|
||||
* Sets the logging level for internal Firebase logging. Firebase will only log messages
|
||||
* that are logged at or below loggerLevel. The messages are logged both to the Xcode
|
||||
* console and to the device's log. Note that if an app is running from AppStore, it will
|
||||
* never log above FIRLoggerLevelNotice even if loggerLevel is set to a higher (more verbose)
|
||||
* setting.
|
||||
*
|
||||
* @param loggerLevel The maximum logging level. The default level is set to FIRLoggerLevelNotice.
|
||||
*/
|
||||
- (void)setLoggerLevel:(FIRLoggerLevel)loggerLevel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Note that importing GULLoggerLevel.h will lead to a non-modular header
|
||||
// import error.
|
||||
|
||||
/**
|
||||
* The log levels used by internal logging.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, FIRLoggerLevel) {
|
||||
/** Error level, matches ASL_LEVEL_ERR. */
|
||||
FIRLoggerLevelError = 3,
|
||||
/** Warning level, matches ASL_LEVEL_WARNING. */
|
||||
FIRLoggerLevelWarning = 4,
|
||||
/** Notice level, matches ASL_LEVEL_NOTICE. */
|
||||
FIRLoggerLevelNotice = 5,
|
||||
/** Info level, matches ASL_LEVEL_INFO. */
|
||||
FIRLoggerLevelInfo = 6,
|
||||
/** Debug level, matches ASL_LEVEL_DEBUG. */
|
||||
FIRLoggerLevelDebug = 7,
|
||||
/** Minimum log level. */
|
||||
FIRLoggerLevelMin = FIRLoggerLevelError,
|
||||
/** Maximum log level. */
|
||||
FIRLoggerLevelMax = FIRLoggerLevelDebug
|
||||
} NS_SWIFT_NAME(FirebaseLoggerLevel);
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* This class provides constant fields of Google APIs.
|
||||
*/
|
||||
NS_SWIFT_NAME(FirebaseOptions)
|
||||
@interface FIROptions : NSObject <NSCopying>
|
||||
|
||||
/**
|
||||
* Returns the default options. The first time this is called it synchronously reads
|
||||
* GoogleService-Info.plist from disk.
|
||||
*/
|
||||
+ (nullable FIROptions *)defaultOptions NS_SWIFT_NAME(defaultOptions());
|
||||
|
||||
/**
|
||||
* An iOS API key used for authenticating requests from your app, e.g.
|
||||
* @"AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *APIKey NS_SWIFT_NAME(apiKey);
|
||||
|
||||
/**
|
||||
* The bundle ID for the application. Defaults to `[[NSBundle mainBundle] bundleID]` when not set
|
||||
* manually or in a plist.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *bundleID;
|
||||
|
||||
/**
|
||||
* The OAuth2 client ID for iOS application used to authenticate Google users, for example
|
||||
* @"12345.apps.googleusercontent.com", used for signing in with Google.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *clientID;
|
||||
|
||||
/**
|
||||
* The tracking ID for Google Analytics, e.g. @"UA-12345678-1", used to configure Google Analytics.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *trackingID;
|
||||
|
||||
/**
|
||||
* The Project Number from the Google Developer's console, for example @"012345678901", used to
|
||||
* configure Google Cloud Messaging.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *GCMSenderID NS_SWIFT_NAME(gcmSenderID);
|
||||
|
||||
/**
|
||||
* The Project ID from the Firebase console, for example @"abc-xyz-123".
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *projectID;
|
||||
|
||||
/**
|
||||
* The Android client ID used in Google AppInvite when an iOS app has its Android version, for
|
||||
* example @"12345.apps.googleusercontent.com".
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *androidClientID;
|
||||
|
||||
/**
|
||||
* The Google App ID that is used to uniquely identify an instance of an app.
|
||||
*/
|
||||
@property(nonatomic, copy) NSString *googleAppID;
|
||||
|
||||
/**
|
||||
* The database root URL, e.g. @"http://abc-xyz-123.firebaseio.com".
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *databaseURL;
|
||||
|
||||
/**
|
||||
* The URL scheme used to set up Durable Deep Link service.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *deepLinkURLScheme;
|
||||
|
||||
/**
|
||||
* The Google Cloud Storage bucket name, e.g. @"abc-xyz-123.storage.firebase.com".
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *storageBucket;
|
||||
|
||||
/**
|
||||
* The App Group identifier to share data between the application and the application extensions.
|
||||
* The App Group must be configured in the application and on the Apple Developer Portal. Default
|
||||
* value `nil`.
|
||||
*/
|
||||
@property(nonatomic, copy, nullable) NSString *appGroupID;
|
||||
|
||||
/**
|
||||
* Initializes a customized instance of FIROptions from the file at the given plist file path. This
|
||||
* will read the file synchronously from disk.
|
||||
* For example,
|
||||
* NSString *filePath =
|
||||
* [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
|
||||
* FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
|
||||
* Returns nil if the plist file does not exist or is invalid.
|
||||
*/
|
||||
- (nullable instancetype)initWithContentsOfFile:(NSString *)plistPath;
|
||||
|
||||
/**
|
||||
* Initializes a customized instance of FIROptions with required fields. Use the mutable properties
|
||||
* to modify fields for configuring specific services.
|
||||
*/
|
||||
// clang-format off
|
||||
- (instancetype)initWithGoogleAppID:(NSString *)googleAppID
|
||||
GCMSenderID:(NSString *)GCMSenderID
|
||||
NS_SWIFT_NAME(init(googleAppID:gcmSenderID:));
|
||||
// clang-format on
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2017 Google
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FIRApp.h"
|
||||
#import "FIRConfiguration.h"
|
||||
#import "FIRLoggerLevel.h"
|
||||
#import "FIROptions.h"
|
||||
Reference in New Issue
Block a user