diff options
author | Paul Beusterien <paulbeusterien@google.com> | 2017-05-15 12:27:07 -0700 |
---|---|---|
committer | Paul Beusterien <paulbeusterien@google.com> | 2017-05-15 12:27:07 -0700 |
commit | 98ba64449a632518bd2b86fe8d927f4a960d3ddc (patch) | |
tree | 131d9c4272fa6179fcda6c5a33fcb3b1bd57ad2e /Firebase/Core/Private | |
parent | 32461366c9e204a527ca05e6e9b9404a2454ac51 (diff) |
Initial
Diffstat (limited to 'Firebase/Core/Private')
18 files changed, 1175 insertions, 0 deletions
diff --git a/Firebase/Core/Private/FIRAnalyticsConfiguration+Internal.h b/Firebase/Core/Private/FIRAnalyticsConfiguration+Internal.h new file mode 100644 index 0000000..6c57a0f --- /dev/null +++ b/Firebase/Core/Private/FIRAnalyticsConfiguration+Internal.h @@ -0,0 +1,39 @@ +/* + * 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 "../FIRAnalyticsConfiguration.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"; diff --git a/Firebase/Core/Private/FIRAppAssociationRegistration.h b/Firebase/Core/Private/FIRAppAssociationRegistration.h new file mode 100644 index 0000000..3d697a7 --- /dev/null +++ b/Firebase/Core/Private/FIRAppAssociationRegistration.h @@ -0,0 +1,48 @@ +/* + * 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 + +/** @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 (^)())creationBlock; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Firebase/Core/Private/FIRAppEnvironmentUtil.h b/Firebase/Core/Private/FIRAppEnvironmentUtil.h new file mode 100644 index 0000000..ba4696c --- /dev/null +++ b/Firebase/Core/Private/FIRAppEnvironmentUtil.h @@ -0,0 +1,48 @@ +/* + * 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 <UIKit/UIKit.h> + +@interface FIRAppEnvironmentUtil : NSObject + +/// Indicates whether the app is from Apple Store or not. Returns NO if the app is on simulator, +/// development environment or sideloaded. ++ (BOOL)isFromAppStore; + +/// Indicates whether the app is a Testflight app. Returns YES if the app has sandbox receipt. +/// Returns NO otherwise. ++ (BOOL)isAppStoreReceiptSandbox; + +/// Indicates whether the app is on simulator or not at runtime depending on the device +/// architecture. ++ (BOOL)isSimulator; + +/// The current device model. Returns an empty string if device model cannot be retrieved. ++ (NSString *)deviceModel; + +/// The current operating system version. Returns an empty string if the system version cannot be +/// retrieved. ++ (NSString *)systemVersion; + +/// Indicates whether it is running inside an extension or an app. ++ (BOOL)isAppExtension; + +/// Returns the [UIApplication sharedApplication] if it is running on an app, not an extension. ++ (UIApplication *)sharedApplication; + +@end diff --git a/Firebase/Core/Private/FIRAppInternal.h b/Firebase/Core/Private/FIRAppInternal.h new file mode 100644 index 0000000..11b3bf6 --- /dev/null +++ b/Firebase/Core/Private/FIRAppInternal.h @@ -0,0 +1,140 @@ +/* + * 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 "FIRErrors.h" + +/** + * 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, +}; + +/** + * Names of services provided by Firebase. + */ +extern NSString *const kFIRServiceAdMob; +extern NSString *const kFIRServiceAuth; +extern NSString *const kFIRServiceCrash; +extern NSString *const kFIRServiceDatabase; +extern NSString *const kFIRServiceDynamicLinks; +extern NSString *const kFIRServiceInstanceID; +extern NSString *const kFIRServiceInvites; +extern NSString *const kFIRServiceMessaging; +extern NSString *const kFIRServiceMeasurement; +extern NSString *const kFIRServiceRemoteConfig; +extern NSString *const kFIRServiceStorage; + +/** + * Names of services provided by the Google pod, but logged by the Firebase pod. + */ +extern NSString *const kGGLServiceAnalytics; +extern NSString *const kGGLServiceSignIn; + +extern NSString *const kFIRDefaultAppName; +extern NSString *const kFIRAppReadyToConfigureSDKNotification; +extern NSString *const kFIRAppDeleteNotification; +extern NSString *const kFIRAppIsDefaultAppKey; +extern NSString *const kFIRAppNameKey; +extern NSString *const kFIRGoogleAppIDKey; + +/** @typedef FIRTokenCallback + @brief The type of block which gets called when a token is ready. + */ +typedef void (^FIRTokenCallback)(NSString *_Nullable token, NSError *_Nullable error); + +/** @typedef FIRAppGetTokenImplementation + @brief The type of block which can provide an implementation for the @c getTokenWithCallback: + method. + @param forceRefresh Forces the token to be refreshed. + @param callback The block which should be invoked when the async call completes. + */ +typedef void (^FIRAppGetTokenImplementation)(BOOL forceRefresh, FIRTokenCallback callback); + +/** @typedef FIRAppGetUID + @brief The type of block which can provide an implementation for the @c getUID method. + */ +typedef NSString *_Nullable (^FIRAppGetUIDImplementation)(); + +@interface FIRApp () + +/** @property getTokenImplementation + @brief Gets or sets the block to use for the implementation of + @c getTokenForcingRefresh:withCallback: + */ +@property(nonatomic, copy) FIRAppGetTokenImplementation getTokenImplementation; + +/** @property getUIDImplementation + @brief Gets or sets the block to use for the implementation of @c getUID. + */ +@property(nonatomic, copy) FIRAppGetUIDImplementation getUIDImplementation; + +/** + * 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; + +/** + * Used by each SDK to send logs about SDK configuration status to Clearcut. + */ +- (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; + +/** @fn getTokenForcingRefresh:withCallback: + @brief Retrieves the Firebase authentication token, possibly refreshing it. + @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason + other than an expiration. + @param callback The block to invoke when the token is available. + */ +- (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback)callback; + +/** + * Exposed for use by the Google pod. Configures the default app without sending notifications to + * other SDKs. Otherwise, behaves exactly like +configure. + */ ++ (void)configureWithoutSendingNotification; + +/** + * Expose the UID of the current user for Firestore. + */ +- (nullable NSString *)getUID; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Firebase/Core/Private/FIRBundleUtil.h b/Firebase/Core/Private/FIRBundleUtil.h new file mode 100644 index 0000000..4bfef8d --- /dev/null +++ b/Firebase/Core/Private/FIRBundleUtil.h @@ -0,0 +1,57 @@ +/* + * 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; + +/** + * Finds bundle identifiers in all relevant bundles, starting with those from [NSBundle mainBundle]. + */ ++ (NSSet *)relevantBundleIdentifiers; + +/** + * Checks if the bundle identifier exists in the given bundles. + */ ++ (BOOL)hasBundleIdentifier:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles; + +@end diff --git a/Firebase/Core/Private/FIRErrorCode.h b/Firebase/Core/Private/FIRErrorCode.h new file mode 100644 index 0000000..01d3c56 --- /dev/null +++ b/Firebase/Core/Private/FIRErrorCode.h @@ -0,0 +1,55 @@ +/* + * 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. + */ + FIRErrorCodeAdMobFailed = -110, + FIRErrorCodeAppInviteFailed = -112, + FIRErrorCodeCloudMessagingFailed = -113, + FIRErrorCodeConfigFailed = -114, + FIRErrorCodeDatabaseFailed = -115, + FIRErrorCodeCrashReportingFailed = -118, + FIRErrorCodeDurableDeepLinkFailed = -119, + FIRErrorCodeAuthFailed = -120, + FIRErrorCodeInstanceIDFailed = -121, + FIRErrorCodeStorageFailed = -123, + + /** + * Error codes returned by Dynamic Links + */ + FIRErrorCodeDynamicLinksStrongMatchNotAvailable = -124, + FIRErrorCodeDynamicLinksManualRetrievalNotEnabled = -125, + FIRErrorCodeDynamicLinksPendingLinkOnlyAvailableAtFirstLaunch = -126, + FIRErrorCodeDynamicLinksPendingLinkRetrievalAlreadyRunning = -127, +}; diff --git a/Firebase/Core/Private/FIRErrors.h b/Firebase/Core/Private/FIRErrors.h new file mode 100644 index 0000000..9a03575 --- /dev/null +++ b/Firebase/Core/Private/FIRErrors.h @@ -0,0 +1,43 @@ +/* + * 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 kFirebaseAdMobErrorDomain; +extern NSString *const kFirebaseAppInviteErrorDomain; +extern NSString *const kFirebaseAuthErrorDomain; +extern NSString *const kFirebaseCloudMessagingErrorDomain; +extern NSString *const kFirebaseConfigErrorDomain; +extern NSString *const kFirebaseCoreErrorDomain; +extern NSString *const kFirebaseCrashReportingErrorDomain; +extern NSString *const kFirebaseDatabaseErrorDomain; +extern NSString *const kFirebaseDurableDeepLinkErrorDomain; +extern NSString *const kFirebaseInstanceIDErrorDomain; +extern NSString *const kFirebasePerfErrorDomain; +extern NSString *const kFirebaseStorageErrorDomain; + +/** + * Factory for a NSError in the Firebase error domain. + * + * @param domain Domain of Firebase error. + * @param code Error code that NSError should have. + * @param userInfo User info that NSError should have. + * @return An NSError in the Firebase domain. + */ +extern NSError *FIRCreateError(NSString *domain, FIRErrorCode code, NSDictionary *userInfo); diff --git a/Firebase/Core/Private/FIRLogger.h b/Firebase/Core/Private/FIRLogger.h new file mode 100644 index 0000000..2206c0a --- /dev/null +++ b/Firebase/Core/Private/FIRLogger.h @@ -0,0 +1,115 @@ +/* + * 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 "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 kFIRLoggerCore; +extern FIRLoggerService kFIRLoggerCrash; +extern FIRLoggerService kFIRLoggerDatabase; +extern FIRLoggerService kFIRLoggerDynamicLinks; +extern FIRLoggerService kFIRLoggerInstanceID; +extern FIRLoggerService kFIRLoggerInvites; +extern FIRLoggerService kFIRLoggerMessaging; +extern FIRLoggerService kFIRLoggerPerf; +extern FIRLoggerService kFIRLoggerRemoteConfig; +extern FIRLoggerService kFIRLoggerStorage; + +/** + * 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_IPHONE_SIMULATOR + 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); + +NS_ASSUME_NONNULL_END diff --git a/Firebase/Core/Private/FIRMutableDictionary.h b/Firebase/Core/Private/FIRMutableDictionary.h new file mode 100644 index 0000000..ebe2d33 --- /dev/null +++ b/Firebase/Core/Private/FIRMutableDictionary.h @@ -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 Foundation; + +/// A mutable dictionary that provides atomic accessor and mutators. +@interface FIRMutableDictionary : NSObject + +/// Returns an object given a key in the dictionary or nil if not found. +- (id)objectForKey:(id)key; + +/// Updates the object given its key or adds it to the dictionary if it is not in the dictionary. +- (void)setObject:(id)object forKey:(id<NSCopying>)key; + +/// Removes the object given its session ID from the dictionary. +- (void)removeObjectForKey:(id)key; + +/// Removes all objects. +- (void)removeAllObjects; + +/// Returns the number of current objects in the dictionary. +- (NSUInteger)count; + +/// Returns an object given a key in the dictionary or nil if not found. +- (id)objectForKeyedSubscript:(id<NSCopying>)key; + +/// Updates the object given its key or adds it to the dictionary if it is not in the dictionary. +- (void)setObject:(id)obj forKeyedSubscript:(id<NSCopying>)key; + +/// Returns the immutable dictionary. +- (NSDictionary *)dictionary; + +@end diff --git a/Firebase/Core/Private/FIRNetwork.h b/Firebase/Core/Private/FIRNetwork.h new file mode 100644 index 0000000..aac0bca --- /dev/null +++ b/Firebase/Core/Private/FIRNetwork.h @@ -0,0 +1,87 @@ +/* + * 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; + +#import "FIRNetworkConstants.h" +#import "FIRNetworkLoggerProtocol.h" +#import "FIRNetworkURLSession.h" + +/// Delegate protocol for FIRNetwork events. +@protocol FIRNetworkReachabilityDelegate + +/// Tells the delegate to handle events when the network reachability changes to connected or not +/// connected. +- (void)reachabilityDidChange; + +@end + +/// The Network component that provides network status and handles network requests and responses. +/// This is not thread safe. +/// +/// NOTE: +/// User must add FIRAnalytics handleEventsForBackgroundURLSessionID:completionHandler to the +/// AppDelegate application:handleEventsForBackgroundURLSession:completionHandler: +@interface FIRNetwork : NSObject + +/// Indicates if network connectivity is available. +@property(nonatomic, readonly, getter=isNetworkConnected) BOOL networkConnected; + +/// Indicates if there are any uploads in progress. +@property(nonatomic, readonly, getter=hasUploadInProgress) BOOL uploadInProgress; + +/// An optional delegate that can be used in the event when network reachability changes. +@property(nonatomic, weak) id<FIRNetworkReachabilityDelegate> reachabilityDelegate; + +/// An optional delegate that can be used to log messages, warnings or errors that occur in the +/// network operations. +@property(nonatomic, weak) id<FIRNetworkLoggerDelegate> loggerDelegate; + +/// Indicates whether the logger should display debug messages. +@property(nonatomic, assign) BOOL isDebugModeEnabled; + +/// The time interval in seconds for the network request to timeout. +@property(nonatomic, assign) NSTimeInterval timeoutInterval; + +/// Initializes with the default reachability host. +- (instancetype)init; + +/// Initializes with a custom reachability host. +- (instancetype)initWithReachabilityHost:(NSString *)reachabilityHost; + +/// Handles events when background session with the given ID has finished. ++ (void)handleEventsForBackgroundURLSessionID:(NSString *)sessionID + completionHandler:(FIRNetworkSystemCompletionHandler)completionHandler; + +/// Compresses and sends a POST request with the provided data to the URL. The session will be +/// background session if usingBackgroundSession is YES. Otherwise, the POST session is default +/// session. Returns a session ID or nil if an error occurs. +- (NSString *)postURL:(NSURL *)url + payload:(NSData *)payload + queue:(dispatch_queue_t)queue + usingBackgroundSession:(BOOL)usingBackgroundSession + completionHandler:(FIRNetworkCompletionHandler)handler; + +/// Sends a GET request with the provided data to the URL. The session will be background session +/// if usingBackgroundSession is YES. Otherwise, the GET session is default session. Returns a +/// session ID or nil if an error occurs. +- (NSString *)getURL:(NSURL *)url + headers:(NSDictionary *)headers + queue:(dispatch_queue_t)queue + usingBackgroundSession:(BOOL)usingBackgroundSession + completionHandler:(FIRNetworkCompletionHandler)handler; + +@end diff --git a/Firebase/Core/Private/FIRNetworkConstants.h b/Firebase/Core/Private/FIRNetworkConstants.h new file mode 100644 index 0000000..5878088 --- /dev/null +++ b/Firebase/Core/Private/FIRNetworkConstants.h @@ -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 Foundation; + +/// Error codes in Firebase Network error domain. +/// Note: these error codes should never change. It would make it harder to decode the errors if +/// we inadvertently altered any of these codes in a future SDK version. +typedef NS_ENUM(NSInteger, FIRNetworkErrorCode) { + /// Unknown error. + FIRNetworkErrorCodeUnknown = 0, + /// Error occurs when the request URL is invalid. + FIRErrorCodeNetworkInvalidURL = 1, + /// Error occurs when request cannot be constructed. + FIRErrorCodeNetworkRequestCreation = 2, + /// Error occurs when payload cannot be compressed. + FIRErrorCodeNetworkPayloadCompression = 3, + /// Error occurs when session task cannot be created. + FIRErrorCodeNetworkSessionTaskCreation = 4, + /// Error occurs when there is no response. + FIRErrorCodeNetworkInvalidResponse = 5 +}; + +#pragma mark - Network constants + +/// The prefix of the ID of the background session. +extern NSString *const kFIRNetworkBackgroundSessionConfigIDPrefix; + +/// The sub directory to store the files of data that is being uploaded in the background. +extern NSString *const kFIRNetworkApplicationSupportSubdirectory; + +/// Name of the temporary directory that stores files for background uploading. +extern NSString *const kFIRNetworkTempDirectoryName; + +/// The period when the temporary uploading file can stay. +extern const NSTimeInterval kFIRNetworkTempFolderExpireTime; + +/// The default network request timeout interval. +extern const NSTimeInterval kFIRNetworkTimeOutInterval; + +/// The host to check the reachability of the network. +extern NSString *const kFIRNetworkReachabilityHost; + +/// The key to get the error context of the UserInfo. +extern NSString *const kFIRNetworkErrorContext; + +#pragma mark - Network Status Code + +extern const int kFIRNetworkHTTPStatusOK; +extern const int kFIRNetworkHTTPStatusNoContent; +extern const int kFIRNetworkHTTPStatusCodeMultipleChoices; +extern const int kFIRNetworkHTTPStatusCodeMovedPermanently; +extern const int kFIRNetworkHTTPStatusCodeFound; +extern const int kFIRNetworkHTTPStatusCodeNotModified; +extern const int kFIRNetworkHTTPStatusCodeMovedTemporarily; +extern const int kFIRNetworkHTTPStatusCodeNotFound; +extern const int kFIRNetworkHTTPStatusCodeCannotAcceptTraffic; +extern const int kFIRNetworkHTTPStatusCodeUnavailable; + +#pragma mark - Error Domain + +extern NSString *const kFIRNetworkErrorDomain; diff --git a/Firebase/Core/Private/FIRNetworkLoggerProtocol.h b/Firebase/Core/Private/FIRNetworkLoggerProtocol.h new file mode 100644 index 0000000..7b7d094 --- /dev/null +++ b/Firebase/Core/Private/FIRNetworkLoggerProtocol.h @@ -0,0 +1,50 @@ +/* + * 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; + +#import "FIRNetworkMessageCode.h" +#import "../FIRLoggerLevel.h" + +/// The log levels used by FIRNetworkLogger. +typedef NS_ENUM(NSInteger, FIRNetworkLogLevel) { + kFIRNetworkLogLevelError = FIRLoggerLevelError, + kFIRNetworkLogLevelWarning = FIRLoggerLevelWarning, + kFIRNetworkLogLevelInfo = FIRLoggerLevelInfo, + kFIRNetworkLogLevelDebug = FIRLoggerLevelDebug, +}; + +@protocol FIRNetworkLoggerDelegate<NSObject> + +@required +/// Tells the delegate to log a message with an array of contexts and the log level. +- (void)firNetwork_logWithLevel:(FIRNetworkLogLevel)logLevel + messageCode:(FIRNetworkMessageCode)messageCode + message:(NSString *)message + contexts:(NSArray *)contexts; + +/// Tells the delegate to log a message with a context and the log level. +- (void)firNetwork_logWithLevel:(FIRNetworkLogLevel)logLevel + messageCode:(FIRNetworkMessageCode)messageCode + message:(NSString *)message + context:(id)context; + +/// Tells the delegate to log a message with the log level. +- (void)firNetwork_logWithLevel:(FIRNetworkLogLevel)logLevel + messageCode:(FIRNetworkMessageCode)messageCode + message:(NSString *)message; + +@end diff --git a/Firebase/Core/Private/FIRNetworkMessageCode.h b/Firebase/Core/Private/FIRNetworkMessageCode.h new file mode 100644 index 0000000..30f562f --- /dev/null +++ b/Firebase/Core/Private/FIRNetworkMessageCode.h @@ -0,0 +1,52 @@ +/* + * 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. + */ + +// Make sure these codes do not overlap with any contained in the FIRAMessageCode enum. +typedef NS_ENUM(NSInteger, FIRNetworkMessageCode) { + // FIRNetwork.m + kFIRNetworkMessageCodeNetwork000 = 900000, // I-NET900000 + kFIRNetworkMessageCodeNetwork001 = 900001, // I-NET900001 + kFIRNetworkMessageCodeNetwork002 = 900002, // I-NET900002 + kFIRNetworkMessageCodeNetwork003 = 900003, // I-NET900003 + // FIRNetworkURLSession.m + kFIRNetworkMessageCodeURLSession000 = 901000, // I-NET901000 + kFIRNetworkMessageCodeURLSession001 = 901001, // I-NET901001 + kFIRNetworkMessageCodeURLSession002 = 901002, // I-NET901002 + kFIRNetworkMessageCodeURLSession003 = 901003, // I-NET901003 + kFIRNetworkMessageCodeURLSession004 = 901004, // I-NET901004 + kFIRNetworkMessageCodeURLSession005 = 901005, // I-NET901005 + kFIRNetworkMessageCodeURLSession006 = 901006, // I-NET901006 + kFIRNetworkMessageCodeURLSession007 = 901007, // I-NET901007 + kFIRNetworkMessageCodeURLSession008 = 901008, // I-NET901008 + kFIRNetworkMessageCodeURLSession009 = 901009, // I-NET901009 + kFIRNetworkMessageCodeURLSession010 = 901010, // I-NET901010 + kFIRNetworkMessageCodeURLSession011 = 901011, // I-NET901011 + kFIRNetworkMessageCodeURLSession012 = 901012, // I-NET901012 + kFIRNetworkMessageCodeURLSession013 = 901013, // I-NET901013 + kFIRNetworkMessageCodeURLSession014 = 901014, // I-NET901014 + kFIRNetworkMessageCodeURLSession015 = 901015, // I-NET901015 + kFIRNetworkMessageCodeURLSession016 = 901016, // I-NET901016 + kFIRNetworkMessageCodeURLSession017 = 901017, // I-NET901017 + kFIRNetworkMessageCodeURLSession018 = 901018, // I-NET901018 + // FIRReachabilityChecker.m + kFIRNetworkMessageCodeReachabilityChecker000 = 902000, // I-NET902000 + kFIRNetworkMessageCodeReachabilityChecker001 = 902001, // I-NET902001 + kFIRNetworkMessageCodeReachabilityChecker002 = 902002, // I-NET902002 + kFIRNetworkMessageCodeReachabilityChecker003 = 902003, // I-NET902003 + kFIRNetworkMessageCodeReachabilityChecker004 = 902004, // I-NET902004 + kFIRNetworkMessageCodeReachabilityChecker005 = 902005, // I-NET902005 + kFIRNetworkMessageCodeReachabilityChecker006 = 902006, // I-NET902006 +}; diff --git a/Firebase/Core/Private/FIRNetworkURLSession.h b/Firebase/Core/Private/FIRNetworkURLSession.h new file mode 100644 index 0000000..d146de2 --- /dev/null +++ b/Firebase/Core/Private/FIRNetworkURLSession.h @@ -0,0 +1,57 @@ +/* + * 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; + +#import "FIRNetworkLoggerProtocol.h" + +typedef void (^FIRNetworkCompletionHandler)(NSHTTPURLResponse *response, NSData *data, + NSError *error); +typedef void (^FIRNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response, NSData *data, + NSString *sessionID, NSError *error); +typedef void (^FIRNetworkSystemCompletionHandler)(void); + +/// The protocol that uses NSURLSession for iOS >= 7.0 to handle requests and responses. +@interface FIRNetworkURLSession + : NSObject<NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate> + +/// Indicates whether the background network is enabled. Default value is NO. +@property(nonatomic, getter=isBackgroundNetworkEnabled) BOOL backgroundNetworkEnabled; + +/// The logger delegate to log message, errors or warnings that occur during the network operations. +@property(nonatomic, weak) id<FIRNetworkLoggerDelegate> loggerDelegate; + +/// Calls the system provided completion handler after the background session is finished. ++ (void)handleEventsForBackgroundURLSessionID:(NSString *)sessionID + completionHandler:(FIRNetworkSystemCompletionHandler)completionHandler; + +/// Initializes with logger delegate. +- (instancetype)initWithNetworkLoggerDelegate:(id<FIRNetworkLoggerDelegate>)networkLoggerDelegate + NS_DESIGNATED_INITIALIZER; + +- (instancetype)init NS_UNAVAILABLE; + +/// Sends an asynchronous POST request and calls the provided completion handler when the request +/// completes or when errors occur, and returns an ID of the session/connection. +- (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request + completionHandler:(FIRNetworkURLSessionCompletionHandler)handler; + +/// Sends an asynchronous GET request and calls the provided completion handler when the request +/// completes or when errors occur, and returns an ID of the session. +- (NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request + completionHandler:(FIRNetworkURLSessionCompletionHandler)handler; + +@end diff --git a/Firebase/Core/Private/FIROptionsInternal.h b/Firebase/Core/Private/FIROptionsInternal.h new file mode 100644 index 0000000..2b30248 --- /dev/null +++ b/Firebase/Core/Private/FIROptionsInternal.h @@ -0,0 +1,108 @@ +/* + * 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 "../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; + +/** + * 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 diff --git a/Firebase/Core/Private/FIRReachabilityChecker+Internal.h b/Firebase/Core/Private/FIRReachabilityChecker+Internal.h new file mode 100644 index 0000000..f82d103 --- /dev/null +++ b/Firebase/Core/Private/FIRReachabilityChecker+Internal.h @@ -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 "FIRReachabilityChecker.h" + +typedef SCNetworkReachabilityRef (*FIRReachabilityCreateWithNameFn)(CFAllocatorRef allocator, + const char *host); + +typedef Boolean (*FIRReachabilitySetCallbackFn)(SCNetworkReachabilityRef target, + SCNetworkReachabilityCallBack callback, + SCNetworkReachabilityContext *context); +typedef Boolean (*FIRReachabilityScheduleWithRunLoopFn)(SCNetworkReachabilityRef target, + CFRunLoopRef runLoop, + CFStringRef runLoopMode); +typedef Boolean (*FIRReachabilityUnscheduleFromRunLoopFn)(SCNetworkReachabilityRef target, + CFRunLoopRef runLoop, + CFStringRef runLoopMode); + +typedef void (*FIRReachabilityReleaseFn)(CFTypeRef cf); + +struct FIRReachabilityApi { + FIRReachabilityCreateWithNameFn createWithNameFn; + FIRReachabilitySetCallbackFn setCallbackFn; + FIRReachabilityScheduleWithRunLoopFn scheduleWithRunLoopFn; + FIRReachabilityUnscheduleFromRunLoopFn unscheduleFromRunLoopFn; + FIRReachabilityReleaseFn releaseFn; +}; + +@interface FIRReachabilityChecker (Internal) + +- (const struct FIRReachabilityApi *)reachabilityApi; +- (void)setReachabilityApi:(const struct FIRReachabilityApi *)reachabilityApi; + +@end diff --git a/Firebase/Core/Private/FIRReachabilityChecker.h b/Firebase/Core/Private/FIRReachabilityChecker.h new file mode 100644 index 0000000..105cd3d --- /dev/null +++ b/Firebase/Core/Private/FIRReachabilityChecker.h @@ -0,0 +1,83 @@ +/* + * 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; +@import SystemConfiguration; + +/// Reachability Status +typedef enum { + kFIRReachabilityUnknown, ///< Have not yet checked or been notified whether host is reachable. + kFIRReachabilityNotReachable, ///< Host is not reachable. + kFIRReachabilityViaWifi, ///< Host is reachable via Wifi. + kFIRReachabilityViaCellular, ///< Host is reachable via cellular. +} FIRReachabilityStatus; + +const NSString *FIRReachabilityStatusString(FIRReachabilityStatus status); + +@class FIRReachabilityChecker; +@protocol FIRNetworkLoggerDelegate; + +/// Google Analytics iOS Reachability Checker. +@protocol FIRReachabilityDelegate +@required +/// Called when network status has changed. +- (void)reachability:(FIRReachabilityChecker *)reachability + statusChanged:(FIRReachabilityStatus)status; +@end + +/// Google Analytics iOS Network Status Checker. +@interface FIRReachabilityChecker : NSObject + +/// The last known reachability status, or FIRReachabilityStatusUnknown if the +/// checker is not active. +@property(nonatomic, readonly) FIRReachabilityStatus reachabilityStatus; +/// The host to which reachability status is to be checked. +@property(nonatomic, copy, readonly) NSString *host; +/// The delegate to be notified of reachability status changes. +@property(nonatomic, weak) id<FIRReachabilityDelegate> reachabilityDelegate; +/// The delegate to be notified to log messages. +@property(nonatomic, weak) id<FIRNetworkLoggerDelegate> loggerDelegate; +/// `YES` if the reachability checker is active, `NO` otherwise. +@property(nonatomic, readonly) BOOL isActive; + +/// Initialize the reachability checker. Note that you must call start to begin checking for and +/// receiving notifications about network status changes. +/// +/// @param reachabilityDelegate The delegate to be notified when reachability status to host +/// changes. +/// +/// @param loggerDelegate The delegate to send log messages to. +/// +/// @param host The name of the host. +/// +- (instancetype)initWithReachabilityDelegate:(id<FIRReachabilityDelegate>)reachabilityDelegate + loggerDelegate:(id<FIRNetworkLoggerDelegate>)loggerDelegate + withHost:(NSString *)host; + +- (instancetype)init NS_UNAVAILABLE; + +/// Start checking for reachability to the specified host. This has no effect if the status +/// checker is already checking for connectivity. +/// +/// @return `YES` if initiating status checking was successful or the status checking has already +/// been initiated, `NO` otherwise. +- (BOOL)start; + +/// Stop checking for reachability to the specified host. This has no effect if the status +/// checker is not checking for connectivity. +- (void)stop; + +@end diff --git a/Firebase/Core/Private/FIRURLSchemeUtil.h b/Firebase/Core/Private/FIRURLSchemeUtil.h new file mode 100644 index 0000000..d4fa961 --- /dev/null +++ b/Firebase/Core/Private/FIRURLSchemeUtil.h @@ -0,0 +1,25 @@ +/* + * 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> + +/** + * Checks whether the URL schemes declared for Google SignIn are valid. + * + * @param urlSchemes The URL schemes to validate. + * @return YES if the schemes are valid; NO otherwise. + */ +extern BOOL fir_areURLSchemesValidForGoogleSignIn(NSArray *urlSchemes); |