+
+/// Game achievement ID (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterAchievementID : @"10_matches_won",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterAchievementID NS_SWIFT_NAME(AnalyticsParameterAchievementID) =
+ @"achievement_id";
+
+/// Ad Network Click ID (NSString). Used for network-specific click IDs which vary in format.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterAdNetworkClickID : @"1234567",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterAdNetworkClickID
+ NS_SWIFT_NAME(AnalyticsParameterAdNetworkClickID) = @"aclid";
+
+/// The store or affiliation from which this transaction occurred (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterAffiliation : @"Google Store",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterAffiliation NS_SWIFT_NAME(AnalyticsParameterAffiliation) =
+ @"affiliation";
+
+/// The individual campaign name, slogan, promo code, etc. Some networks have pre-defined macro to
+/// capture campaign information, otherwise can be populated by developer. Highly Recommended
+/// (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCampaign : @"winter_promotion",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCampaign NS_SWIFT_NAME(AnalyticsParameterCampaign) =
+ @"campaign";
+
+/// Character used in game (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCharacter : @"beat_boss",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCharacter NS_SWIFT_NAME(AnalyticsParameterCharacter) =
+ @"character";
+
+/// The checkout step (1..N) (unsigned 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCheckoutStep : @"1",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCheckoutStep NS_SWIFT_NAME(AnalyticsParameterCheckoutStep) =
+ @"checkout_step";
+
+/// Some option on a step in an ecommerce flow (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCheckoutOption : @"Visa",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCheckoutOption
+ NS_SWIFT_NAME(AnalyticsParameterCheckoutOption) = @"checkout_option";
+
+/// Campaign content (NSString).
+static NSString *const kFIRParameterContent NS_SWIFT_NAME(AnalyticsParameterContent) = @"content";
+
+/// Type of content selected (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterContentType : @"news article",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterContentType NS_SWIFT_NAME(AnalyticsParameterContentType) =
+ @"content_type";
+
+/// Coupon code for a purchasable item (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCoupon : @"zz123",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCoupon NS_SWIFT_NAME(AnalyticsParameterCoupon) = @"coupon";
+
+/// Campaign custom parameter (NSString). Used as a method of capturing custom data in a campaign.
+/// Use varies by network.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCP1 : @"custom_data",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCP1 NS_SWIFT_NAME(AnalyticsParameterCP1) = @"cp1";
+
+/// The name of a creative used in a promotional spot (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCreativeName : @"Summer Sale",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCreativeName NS_SWIFT_NAME(AnalyticsParameterCreativeName) =
+ @"creative_name";
+
+/// The name of a creative slot (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCreativeSlot : @"summer_banner2",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCreativeSlot NS_SWIFT_NAME(AnalyticsParameterCreativeSlot) =
+ @"creative_slot";
+
+/// Purchase currency in 3-letter
+/// ISO_4217 format (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterCurrency : @"USD",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterCurrency NS_SWIFT_NAME(AnalyticsParameterCurrency) =
+ @"currency";
+
+/// Flight or Travel destination (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterDestination : @"Mountain View, CA",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterDestination NS_SWIFT_NAME(AnalyticsParameterDestination) =
+ @"destination";
+
+/// The arrival date, check-out date or rental end date for the item. This should be in
+/// YYYY-MM-DD format (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterEndDate : @"2015-09-14",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterEndDate NS_SWIFT_NAME(AnalyticsParameterEndDate) = @"end_date";
+
+/// Flight number for travel events (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterFlightNumber : @"ZZ800",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterFlightNumber NS_SWIFT_NAME(AnalyticsParameterFlightNumber) =
+ @"flight_number";
+
+/// Group/clan/guild ID (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterGroupID : @"g1",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterGroupID NS_SWIFT_NAME(AnalyticsParameterGroupID) = @"group_id";
+
+/// Index of an item in a list (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterIndex : @(1),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterIndex NS_SWIFT_NAME(AnalyticsParameterIndex) = @"index";
+
+/// Item brand (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemBrand : @"Google",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemBrand NS_SWIFT_NAME(AnalyticsParameterItemBrand) =
+ @"item_brand";
+
+/// Item category (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemCategory : @"t-shirts",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemCategory NS_SWIFT_NAME(AnalyticsParameterItemCategory) =
+ @"item_category";
+
+/// Item ID (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemID : @"p7654",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemID NS_SWIFT_NAME(AnalyticsParameterItemID) = @"item_id";
+
+/// The Google Place ID (NSString) that
+/// corresponds to the associated item. Alternatively, you can supply your own custom Location ID.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemLocationID : @"ChIJiyj437sx3YAR9kUWC8QkLzQ",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemLocationID
+ NS_SWIFT_NAME(AnalyticsParameterItemLocationID) = @"item_location_id";
+
+/// Item name (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemName : @"abc",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemName NS_SWIFT_NAME(AnalyticsParameterItemName) =
+ @"item_name";
+
+/// The list in which the item was presented to the user (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemList : @"Search Results",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemList NS_SWIFT_NAME(AnalyticsParameterItemList) =
+ @"item_list";
+
+/// Item variant (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterItemVariant : @"Red",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterItemVariant NS_SWIFT_NAME(AnalyticsParameterItemVariant) =
+ @"item_variant";
+
+/// Level in game (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterLevel : @(42),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterLevel NS_SWIFT_NAME(AnalyticsParameterLevel) = @"level";
+
+/// Location (NSString). The Google Place ID
+/// that corresponds to the associated event. Alternatively, you can supply your own custom
+/// Location ID.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterLocation : @"ChIJiyj437sx3YAR9kUWC8QkLzQ",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterLocation NS_SWIFT_NAME(AnalyticsParameterLocation) =
+ @"location";
+
+/// The advertising or marketing medium, for example: cpc, banner, email, push. Highly recommended
+/// (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterMedium : @"email",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterMedium NS_SWIFT_NAME(AnalyticsParameterMedium) = @"medium";
+
+/// Number of nights staying at hotel (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterNumberOfNights : @(3),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterNumberOfNights
+ NS_SWIFT_NAME(AnalyticsParameterNumberOfNights) = @"number_of_nights";
+
+/// Number of passengers traveling (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterNumberOfPassengers : @(11),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterNumberOfPassengers
+ NS_SWIFT_NAME(AnalyticsParameterNumberOfPassengers) = @"number_of_passengers";
+
+/// Number of rooms for travel events (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterNumberOfRooms : @(2),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterNumberOfRooms NS_SWIFT_NAME(AnalyticsParameterNumberOfRooms) =
+ @"number_of_rooms";
+
+/// Flight or Travel origin (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterOrigin : @"Mountain View, CA",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterOrigin NS_SWIFT_NAME(AnalyticsParameterOrigin) = @"origin";
+
+/// Purchase price (double as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterPrice : @(1.0),
+/// kFIRParameterCurrency : @"USD", // e.g. $1.00 USD
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterPrice NS_SWIFT_NAME(AnalyticsParameterPrice) = @"price";
+
+/// Purchase quantity (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterQuantity : @(1),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterQuantity NS_SWIFT_NAME(AnalyticsParameterQuantity) =
+ @"quantity";
+
+/// Score in game (signed 64-bit integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterScore : @(4200),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterScore NS_SWIFT_NAME(AnalyticsParameterScore) = @"score";
+
+/// The search string/keywords used (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterSearchTerm : @"periodic table",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterSearchTerm NS_SWIFT_NAME(AnalyticsParameterSearchTerm) =
+ @"search_term";
+
+/// Shipping cost (double as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterShipping : @(9.50),
+/// kFIRParameterCurrency : @"USD", // e.g. $9.50 USD
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterShipping NS_SWIFT_NAME(AnalyticsParameterShipping) =
+ @"shipping";
+
+/// Sign up method (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterSignUpMethod : @"google",
+/// // ...
+/// };
+///
+///
+/// This constant has been deprecated. Use Method constant instead.
+static NSString *const kFIRParameterSignUpMethod NS_SWIFT_NAME(AnalyticsParameterSignUpMethod) =
+ @"sign_up_method";
+
+/// A particular approach used in an operation; for example, "facebook" or "email" in the context
+/// of a sign_up or login event. (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterMethod : @"google",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterMethod NS_SWIFT_NAME(AnalyticsParameterMethod) = @"method";
+
+/// The origin of your traffic, such as an Ad network (for example, google) or partner (urban
+/// airship). Identify the advertiser, site, publication, etc. that is sending traffic to your
+/// property. Highly recommended (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterSource : @"InMobi",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterSource NS_SWIFT_NAME(AnalyticsParameterSource) = @"source";
+
+/// The departure date, check-in date or rental start date for the item. This should be in
+/// YYYY-MM-DD format (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterStartDate : @"2015-09-14",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterStartDate NS_SWIFT_NAME(AnalyticsParameterStartDate) =
+ @"start_date";
+
+/// Tax amount (double as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterTax : @(1.0),
+/// kFIRParameterCurrency : @"USD", // e.g. $1.00 USD
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterTax NS_SWIFT_NAME(AnalyticsParameterTax) = @"tax";
+
+/// If you're manually tagging keyword campaigns, you should use utm_term to specify the keyword
+/// (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterTerm : @"game",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterTerm NS_SWIFT_NAME(AnalyticsParameterTerm) = @"term";
+
+/// A single ID for a ecommerce group transaction (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterTransactionID : @"ab7236dd9823",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterTransactionID NS_SWIFT_NAME(AnalyticsParameterTransactionID) =
+ @"transaction_id";
+
+/// Travel class (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterTravelClass : @"business",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterTravelClass NS_SWIFT_NAME(AnalyticsParameterTravelClass) =
+ @"travel_class";
+
+/// A context-specific numeric value which is accumulated automatically for each event type. This is
+/// a general purpose parameter that is useful for accumulating a key metric that pertains to an
+/// event. Examples include revenue, distance, time and points. Value should be specified as signed
+/// 64-bit integer or double as NSNumber. Notes: Values for pre-defined currency-related events
+/// (such as @c kFIREventAddToCart) should be supplied using double as NSNumber and must be
+/// accompanied by a @c kFIRParameterCurrency parameter. The valid range of accumulated values is
+/// [-9,223,372,036,854.77, 9,223,372,036,854.77]. Supplying a non-numeric value, omitting the
+/// corresponding @c kFIRParameterCurrency parameter, or supplying an invalid
+/// currency code for conversion events will cause that
+/// conversion to be omitted from reporting.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterValue : @(3.99),
+/// kFIRParameterCurrency : @"USD", // e.g. $3.99 USD
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterValue NS_SWIFT_NAME(AnalyticsParameterValue) = @"value";
+
+/// Name of virtual currency type (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterVirtualCurrencyName : @"virtual_currency_name",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterVirtualCurrencyName
+ NS_SWIFT_NAME(AnalyticsParameterVirtualCurrencyName) = @"virtual_currency_name";
+
+/// The name of a level in a game (NSString).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterLevelName : @"room_1",
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterLevelName NS_SWIFT_NAME(AnalyticsParameterLevelName) =
+ @"level_name";
+
+/// The result of an operation. Specify 1 to indicate success and 0 to indicate failure (unsigned
+/// integer as NSNumber).
+///
+/// NSDictionary *params = @{
+/// kFIRParameterSuccess : @(1),
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterSuccess NS_SWIFT_NAME(AnalyticsParameterSuccess) = @"success";
+
+/// Indicates that the associated event should either extend the current session
+/// or start a new session if no session was active when the event was logged.
+/// Specify YES to extend the current session or to start a new session; any
+/// other value will not extend or start a session.
+///
+/// NSDictionary *params = @{
+/// kFIRParameterExtendSession : @YES,
+/// // ...
+/// };
+///
+static NSString *const kFIRParameterExtendSession NS_SWIFT_NAME(AnalyticsParameterExtendSession) =
+ @"extend_session";
diff --git a/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h
new file mode 100755
index 00000000..132aef77
--- /dev/null
+++ b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h
@@ -0,0 +1,29 @@
+/// @file FIRUserPropertyNames.h
+///
+/// Predefined user property names.
+///
+/// A UserProperty is an attribute that describes the app-user. By supplying UserProperties, you can
+/// later analyze different behaviors of various segments of your userbase. You may supply up to 25
+/// unique UserProperties per app, and you can use the name and value of your choosing for each one.
+/// UserProperty names can be up to 24 characters long, may only contain alphanumeric characters and
+/// underscores ("_"), and must start with an alphabetic character. UserProperty values can be up to
+/// 36 characters long. The "firebase_", "google_", and "ga_" prefixes are reserved and should not
+/// be used.
+
+#import
+
+/// The method used to sign in. For example, "google", "facebook" or "twitter".
+static NSString *const kFIRUserPropertySignUpMethod
+ NS_SWIFT_NAME(AnalyticsUserPropertySignUpMethod) = @"sign_up_method";
+
+/// Indicates whether events logged by Google Analytics can be used to personalize ads for the user.
+/// Set to "YES" to enable, or "NO" to disable. Default is enabled. See the
+/// documentation for
+/// more details and information about related settings.
+///
+///
+/// [FIRAnalytics setUserPropertyString:@"NO"
+/// forName:kFIRUserPropertyAllowAdPersonalizationSignals];
+///
+static NSString *const kFIRUserPropertyAllowAdPersonalizationSignals
+ NS_SWIFT_NAME(AnalyticsUserPropertyAllowAdPersonalizationSignals) = @"allow_personalized_ads";
diff --git a/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h
new file mode 100755
index 00000000..ed7588a6
--- /dev/null
+++ b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h
@@ -0,0 +1,5 @@
+#import "FIRAnalytics+AppDelegate.h"
+#import "FIRAnalytics.h"
+#import "FIREventNames.h"
+#import "FIRParameterNames.h"
+#import "FIRUserPropertyNames.h"
diff --git a/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap
new file mode 100755
index 00000000..d7c59054
--- /dev/null
+++ b/backup ios/Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap
@@ -0,0 +1,12 @@
+framework module FirebaseAnalytics {
+ umbrella header "FirebaseAnalytics.h"
+ export *
+ module * { export * }
+ link "sqlite3"
+ link "z"
+ link framework "CoreData"
+ link framework "Security"
+ link framework "StoreKit"
+ link framework "SystemConfiguration"
+ link framework "UIKit"
+}
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAnalyticsConfiguration.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAnalyticsConfiguration.m
new file mode 100644
index 00000000..3a7d6de0
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAnalyticsConfiguration.m
@@ -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
+
+#import "FirebaseCore/Sources/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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRApp.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRApp.m
new file mode 100644
index 00000000..02f3ac3f
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRApp.m
@@ -0,0 +1,912 @@
+// 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
+
+#if __has_include()
+#import
+#endif
+
+#if __has_include()
+#import
+#endif
+
+#import
+
+#import "FirebaseCore/Sources/FIRBundleUtil.h"
+#import "FirebaseCore/Sources/FIRVersion.h"
+#import "FirebaseCore/Sources/Private/FIRAnalyticsConfiguration.h"
+#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
+#import "FirebaseCore/Sources/Private/FIRComponentContainerInternal.h"
+#import "FirebaseCore/Sources/Private/FIRConfigurationInternal.h"
+#import "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h"
+#import "FirebaseCore/Sources/Private/FIRLibrary.h"
+#import "FirebaseCore/Sources/Private/FIRLogger.h"
+#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
+
+#import
+
+#import
+
+// 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> *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;
+static dispatch_once_t sFirebaseUserAgentOnceToken;
+
++ (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) {
+ // The default app already exixts. Handle duplicate `configure` calls and return.
+ [self appWasConfiguredTwice:sDefaultApp usingOptions:options];
+ return;
+ }
+
+ 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]) {
+ // The app already exists. Handle a duplicate `configure` call and return.
+ [self appWasConfiguredTwice:sAllApps[name] usingOptions:options];
+ return;
+ }
+ }
+
+ 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];
+
+ // The FIRApp instance is ready to go, `sDefaultApp` is assigned, other SDKs are now ready to be
+ // instantiated.
+ [app.container instantiateEagerComponents];
+ [FIRApp sendNotificationsToSDKs:app];
+ }
+}
+
+/// Called when `configure` has been called multiple times for the same app. This can either throw
+/// an exception (most cases) or ignore the duplicate configuration in situations where it's allowed
+/// like an extension.
++ (void)appWasConfiguredTwice:(FIRApp *)app usingOptions:(FIROptions *)options {
+ // Only extensions should potentially be able to call `configure` more than once.
+ if (![GULAppEnvironmentUtil isAppExtension]) {
+ // Throw an exception since this is now an invalid state.
+ if (app.isDefaultApp) {
+ [NSException raise:kFirebaseCoreErrorDomain
+ format:@"Default app has already been configured."];
+ } else {
+ [NSException raise:kFirebaseCoreErrorDomain
+ format:@"App named %@ has already been configured.", app.name];
+ }
+ }
+
+ // In an extension, the entry point could be called multiple times. As long as the options are
+ // identical we should allow multiple `configure` calls.
+ if ([options isEqual:app.options]) {
+ // Everything is identical but the extension's lifecycle triggered `configure` twice.
+ // Ignore duplicate calls and return since everything should still be in a valid state.
+ FIRLogDebug(kFIRLoggerCore, @"I-COR000035",
+ @"Ignoring second `configure` call in an extension.");
+ return;
+ } else {
+ [NSException raise:kFirebaseCoreErrorDomain
+ format:@"App named %@ has already been configured.", app.name];
+ }
+}
+
++ (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;
+ sFirebaseUserAgentOnceToken = 0;
+ }
+}
+
+- (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 isAnalyticsCollectionExplicitlySet]) {
+ 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 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)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) {
+ dispatch_once(&sFirebaseUserAgentOnceToken, ^{
+ // Report FirebaseCore version for useragent string
+ [FIRApp registerLibrary:@"fire-ios"
+ withVersion:[NSString stringWithUTF8String:FIRCoreVersionString]];
+
+ NSDictionary *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];
+ }
+
+ NSString *swiftFlagValue = [self hasSwiftRuntime] ? @"true" : @"false";
+ [FIRApp registerLibrary:@"swift" withVersion:swiftFlagValue];
+ });
+
+ NSMutableArray *libraries =
+ [[NSMutableArray alloc] initWithCapacity:sLibraryVersions.count];
+ for (NSString *libraryName in sLibraryVersions) {
+ [libraries addObject:[NSString stringWithFormat:@"%@/%@", libraryName,
+ sLibraryVersions[libraryName]]];
+ }
+ [libraries sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
+ return [libraries componentsJoinedByString:@" "];
+ }
+}
+
++ (BOOL)hasSwiftRuntime {
+ // The class
+ // [Swift._SwiftObject](https://github.com/apple/swift/blob/5eac3e2818eb340b11232aff83edfbd1c307fa03/stdlib/public/runtime/SwiftObject.h#L35)
+ // is a part of Swift runtime, so it should be present if Swift runtime is available.
+
+ BOOL hasSwiftRuntime =
+ objc_lookUpClass("Swift._SwiftObject") != nil ||
+ // Swift object class name before
+ // https://github.com/apple/swift/commit/9637b4a6e11ddca72f5f6dbe528efc7c92f14d01
+ objc_getClass("_TtCs12_SwiftObject") != nil;
+
+ return hasSwiftRuntime;
+}
+
+- (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
+ * '::ios:'.
+ *
+ * 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
+ // '**::ios:'
+ if (![stringScanner scanString:version intoString:NULL]) {
+ // The version part is missing or mismatched
+ return NO;
+ }
+
+ // Validate version part (see part between '*' symbols below)
+ // '*:*:ios:'
+ if (![stringScanner scanString:@":" intoString:NULL]) {
+ // appIDVersion must be separated by ":"
+ return NO;
+ }
+
+ // Validate version part (see part between '*' symbols below)
+ // ':**:ios:'.
+ NSInteger projectNumber = NSNotFound;
+ if (![stringScanner scanInteger:&projectNumber]) {
+ // NO project number found.
+ return NO;
+ }
+
+ // Validate version part (see part between '*' symbols below)
+ // ':*:*ios:'.
+ if (![stringScanner scanString:@":" intoString:NULL]) {
+ // The project number must be separated by ":"
+ return NO;
+ }
+
+ // Validate version part (see part between '*' symbols below)
+ // '::*ios*:'.
+ 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)
+ // '::ios*:*'.
+ if (![stringScanner scanString:@":" intoString:NULL]) {
+ // The platform must be separated by ":"
+ return NO;
+ }
+
+ // Validate version part (see part between '*' symbols below)
+ // '::ios:**'.
+ 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;
+#elif TARGET_OS_OSX
+ NSNotificationName notificationName = NSApplicationDidBecomeActiveNotification;
+#endif
+
+#if !TARGET_OS_WATCH
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(appDidBecomeActive:)
+ name:notificationName
+ object:nil];
+#endif
+}
+
+- (void)appDidBecomeActive:(NSNotification *)notification {
+ [self logCoreTelemetryIfEnabled];
+}
+
+- (void)logCoreTelemetryIfEnabled {
+ if ([self isDataCollectionDefaultEnabled]) {
+ [FIRCoreDiagnosticsConnector logCoreTelemetryWithOptions:_options];
+ }
+}
+
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAppAssociationRegistration.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAppAssociationRegistration.m
new file mode 100644
index 00000000..e4125cd2
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRAppAssociationRegistration.m
@@ -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 "FirebaseCore/Sources/Private/FIRAppAssociationRegistration.h"
+
+#import
+
+@implementation FIRAppAssociationRegistration
+
++ (nullable id)registeredObjectWithHost:(id)host
+ key:(NSString *)key
+ creationBlock:(id _Nullable (^)(void))creationBlock {
+ @synchronized(self) {
+ SEL dictKey = @selector(registeredObjectWithHost:key:creationBlock:);
+ NSMutableDictionary *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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.h b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.h
new file mode 100644
index 00000000..d9475dd2
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.h
@@ -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
+
+/**
+ * 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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.m
new file mode 100644
index 00000000..b858f14c
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRBundleUtil.m
@@ -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 "FirebaseCore/Sources/FIRBundleUtil.h"
+
+#import
+
+@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 *bundleIDComponents =
+ [[bundleIdentifier componentsSeparatedByString:bundleIDComponentsSeparator] mutableCopy];
+ [bundleIDComponents removeLastObject];
+
+ return [bundleIDComponents componentsJoinedByString:bundleIDComponentsSeparator];
+}
+
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponent.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponent.m
new file mode 100644
index 00000000..9c1fbed3
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponent.m
@@ -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 "FirebaseCore/Sources/Private/FIRComponent.h"
+
+#import "FirebaseCore/Sources/Private/FIRComponentContainer.h"
+#import "FirebaseCore/Sources/Private/FIRDependency.h"
+
+@interface FIRComponent ()
+
+- (instancetype)initWithProtocol:(Protocol *)protocol
+ instantiationTiming:(FIRInstantiationTiming)instantiationTiming
+ dependencies:(NSArray *)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 *)dependencies
+ creationBlock:(FIRComponentCreationBlock)creationBlock {
+ return [[FIRComponent alloc] initWithProtocol:protocol
+ instantiationTiming:instantiationTiming
+ dependencies:dependencies
+ creationBlock:creationBlock];
+}
+
+- (instancetype)initWithProtocol:(Protocol *)protocol
+ instantiationTiming:(FIRInstantiationTiming)instantiationTiming
+ dependencies:(NSArray *)dependencies
+ creationBlock:(FIRComponentCreationBlock)creationBlock {
+ self = [super init];
+ if (self) {
+ _protocol = protocol;
+ _instantiationTiming = instantiationTiming;
+ _dependencies = [dependencies copy];
+ _creationBlock = creationBlock;
+ }
+ return self;
+}
+
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentContainer.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentContainer.m
new file mode 100644
index 00000000..9f91786f
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentContainer.m
@@ -0,0 +1,208 @@
+/*
+ * 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 "FirebaseCore/Sources/Private/FIRComponentContainer.h"
+
+#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
+#import "FirebaseCore/Sources/Private/FIRComponent.h"
+#import "FirebaseCore/Sources/Private/FIRLibrary.h"
+#import "FirebaseCore/Sources/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 *components;
+
+/// Cached instances of components that requested to be cached.
+@property(nonatomic, strong) NSMutableDictionary *cachedInstances;
+
+/// Protocols of components that have requested to be eagerly instantiated.
+@property(nonatomic, strong, nullable) NSMutableArray *eagerProtocolsToInstantiate;
+
+@end
+
+@implementation FIRComponentContainer
+
+// Collection of all classes that register to provide components.
+static NSMutableSet *sFIRComponentRegistrants;
+
+#pragma mark - Public Registration
+
++ (void)registerAsComponentRegistrant:(Class)klass {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ sFIRComponentRegistrants = [[NSMutableSet alloc] init];
+ });
+
+ [self registerAsComponentRegistrant:klass inSet:sFIRComponentRegistrants];
+}
+
++ (void)registerAsComponentRegistrant:(Class)klass
+ inSet:(NSMutableSet *)allRegistrants {
+ [allRegistrants addObject:klass];
+}
+
+#pragma mark - Internal Initialization
+
+- (instancetype)initWithApp:(FIRApp *)app {
+ return [self initWithApp:app registrants:sFIRComponentRegistrants];
+}
+
+- (instancetype)initWithApp:(FIRApp *)app registrants:(NSMutableSet *)allRegistrants {
+ self = [super init];
+ if (self) {
+ _app = app;
+ _cachedInstances = [NSMutableDictionary dictionary];
+ _components = [NSMutableDictionary dictionary];
+
+ [self populateComponentsFromRegisteredClasses:allRegistrants forApp:app];
+ }
+ return self;
+}
+
+- (void)populateComponentsFromRegisteredClasses:(NSSet *)classes forApp:(FIRApp *)app {
+ // Keep track of any components that need to eagerly instantiate after all components are added.
+ self.eagerProtocolsToInstantiate = [[NSMutableArray alloc] init];
+
+ // Loop through the verified component registrants and populate the components array.
+ for (Class 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;
+
+ // Queue any protocols that should be eagerly instantiated. Don't instantiate them yet
+ // because they could depend on other components that haven't been added to the components
+ // array yet.
+ BOOL shouldInstantiateEager =
+ (component.instantiationTiming == FIRInstantiationTimingAlwaysEager);
+ BOOL shouldInstantiateDefaultEager =
+ (component.instantiationTiming == FIRInstantiationTimingEagerInDefaultApp &&
+ [app isDefaultApp]);
+ if (shouldInstantiateEager || shouldInstantiateDefaultEager) {
+ [self.eagerProtocolsToInstantiate addObject:component.protocol];
+ }
+ }
+ }
+}
+
+#pragma mark - Instance Creation
+
+- (void)instantiateEagerComponents {
+ // After all components are registered, instantiate the ones that are requesting eager
+ // instantiation.
+ @synchronized(self) {
+ for (Protocol *protocol in self.eagerProtocolsToInstantiate) {
+ // Get an instance for the protocol, which will instantiate it since it couldn't have been
+ // cached yet. Ignore the instance coming back since we don't need it.
+ __unused id unusedInstance = [self instanceForProtocol:protocol];
+ }
+
+ // All eager instantiation is complete, clear the stored property now.
+ self.eagerProtocolsToInstantiate = nil;
+ }
+}
+
+/// 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
+///
+/// Note that this method assumes the caller already has @sychronized on self.
+- (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;
+ @synchronized(self) {
+ cachedInstance = self.cachedInstances[protocolName];
+ if (!cachedInstance) {
+ // Use the creation block to instantiate an instance and return it.
+ FIRComponentCreationBlock creationBlock = self.components[protocolName];
+ cachedInstance = [self instantiateInstanceForProtocol:protocol withBlock:creationBlock];
+ }
+ }
+ return cachedInstance;
+}
+
+#pragma mark - Lifecycle
+
+- (void)removeAllCachedInstances {
+ @synchronized(self) {
+ // 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];
+ }
+ }
+
+ // Empty the cache.
+ [self.cachedInstances removeAllObjects];
+ }
+}
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentType.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentType.m
new file mode 100644
index 00000000..6410f2ea
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRComponentType.m
@@ -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 "FirebaseCore/Sources/Private/FIRComponentType.h"
+
+#import "FirebaseCore/Sources/Private/FIRComponentContainerInternal.h"
+
+@implementation FIRComponentType
+
++ (id)instanceForProtocol:(Protocol *)protocol inContainer:(FIRComponentContainer *)container {
+ // Forward the call to the container.
+ return [container instanceForProtocol:protocol];
+}
+
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRConfiguration.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRConfiguration.m
new file mode 100644
index 00000000..a1c9f4a2
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRConfiguration.m
@@ -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 "FirebaseCore/Sources/Private/FIRConfigurationInternal.h"
+
+#import "FirebaseCore/Sources/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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRCoreDiagnosticsConnector.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRCoreDiagnosticsConnector.m
new file mode 100644
index 00000000..4981ca1b
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRCoreDiagnosticsConnector.m
@@ -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 "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h"
+
+#import
+
+#import
+
+#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
+#import "FirebaseCore/Sources/Private/FIRDiagnosticsData.h"
+#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
+
+// Define the interop class symbol declared as an extern in FIRCoreDiagnosticsInterop.
+Class 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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDependency.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDependency.m
new file mode 100644
index 00000000..e1e25783
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDependency.m
@@ -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 "FirebaseCore/Sources/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
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDiagnosticsData.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDiagnosticsData.m
new file mode 100644
index 00000000..bbe0561d
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRDiagnosticsData.m
@@ -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 "FirebaseCore/Sources/Private/FIRDiagnosticsData.h"
+
+#import
+
+#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
+#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
+
+@implementation FIRDiagnosticsData {
+ /** Backing ivar for the diagnosticObjects property. */
+ NSMutableDictionary *_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 *)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 *)diagnosticObjects {
+ NSAssert(NO, @"Please use -insertValue:forKey:");
+}
+#pragma clang diagnostic pop
+
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRErrors.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRErrors.m
new file mode 100644
index 00000000..104eeb82
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRErrors.m
@@ -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 "FirebaseCore/Sources/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";
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRHeartbeatInfo.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRHeartbeatInfo.m
new file mode 100644
index 00000000..f1359f5d
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRHeartbeatInfo.m
@@ -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 "FirebaseCore/Sources/Private/FIRHeartbeatInfo.h"
+#import
+#import
+
+const static long secondsInDay = 864000;
+@implementation FIRHeartbeatInfo : NSObject
+
+/** Updates the storage with the heartbeat information corresponding to this tag.
+ * @param heartbeatTag Tag which could either be sdk specific tag or the global tag.
+ * @return Boolean representing whether the heartbeat needs to be sent for this tag or not.
+ */
++ (BOOL)updateIfNeededHeartbeatDateForTag:(NSString *)heartbeatTag {
+ @synchronized(self) {
+ NSString *const kHeartbeatStorageFile = @"HEARTBEAT_INFO_STORAGE";
+ GULHeartbeatDateStorage *dataStorage =
+ [[GULHeartbeatDateStorage alloc] initWithFileName:kHeartbeatStorageFile];
+ NSDate *heartbeatTime = [dataStorage heartbeatDateForTag:heartbeatTag];
+ NSDate *currentDate = [NSDate date];
+ if (heartbeatTime != nil) {
+ NSTimeInterval secondsBetween = [currentDate timeIntervalSinceDate:heartbeatTime];
+ if (secondsBetween < secondsInDay) {
+ return false;
+ }
+ }
+ return [dataStorage setHearbeatDate:currentDate forTag:heartbeatTag];
+ }
+}
+
++ (FIRHeartbeatInfoCode)heartbeatCodeForTag:(NSString *)heartbeatTag {
+ NSString *globalTag = @"GLOBAL";
+ BOOL isSdkHeartbeatNeeded = [FIRHeartbeatInfo updateIfNeededHeartbeatDateForTag:heartbeatTag];
+ BOOL isGlobalHeartbeatNeeded = [FIRHeartbeatInfo updateIfNeededHeartbeatDateForTag:globalTag];
+ if (!isSdkHeartbeatNeeded && !isGlobalHeartbeatNeeded) {
+ // Both sdk and global heartbeat not needed.
+ return FIRHeartbeatInfoCodeNone;
+ } else if (isSdkHeartbeatNeeded && !isGlobalHeartbeatNeeded) {
+ // Only SDK heartbeat needed.
+ return FIRHeartbeatInfoCodeSDK;
+ } else if (!isSdkHeartbeatNeeded && isGlobalHeartbeatNeeded) {
+ // Only global heartbeat needed.
+ return FIRHeartbeatInfoCodeGlobal;
+ } else {
+ // Both sdk and global heartbeat are needed.
+ return FIRHeartbeatInfoCodeCombined;
+ }
+}
+@end
diff --git a/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRLogger.m b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRLogger.m
new file mode 100644
index 00000000..ba2ee1f5
--- /dev/null
+++ b/backup ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRLogger.m
@@ -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 "FirebaseCore/Sources/Private/FIRLogger.h"
+
+#import
+#import
+#import
+
+#import "FirebaseCore/Sources/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]