diff options
author | Ryan Wilson <wilsonryan@google.com> | 2018-01-04 14:21:01 -0500 |
---|---|---|
committer | Ryan Wilson <wilsonryan@google.com> | 2018-04-09 12:16:57 -0400 |
commit | b8fdf488334da608d701117330692e60376e6fbd (patch) | |
tree | 8a278417dc5abd5506aa0681b838416cf25872a0 | |
parent | 21a6e1f930936eae1bca743430347288fa5e39c8 (diff) |
Remove old FIROptions constructor. (#615)
-rw-r--r-- | Example/Core/Tests/FIRAppTest.m | 40 | ||||
-rw-r--r-- | Example/Core/Tests/FIROptionsTest.m | 68 | ||||
-rw-r--r-- | Firebase/Core/FIROptions.m | 39 | ||||
-rw-r--r-- | Firebase/Core/Public/FIROptions.h | 19 |
4 files changed, 25 insertions, 141 deletions
diff --git a/Example/Core/Tests/FIRAppTest.m b/Example/Core/Tests/FIRAppTest.m index 3784a6e..6825e6a 100644 --- a/Example/Core/Tests/FIRAppTest.m +++ b/Example/Core/Tests/FIRAppTest.m @@ -119,21 +119,11 @@ NSString *const kFIRTestAppName2 = @"test-app-name-2"; } - (void)testConfigureWithCustomizedOptions { -// valid customized options -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnonnull" -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID - bundleID:kBundleID - GCMSenderID:kGCMSenderID - APIKey:kCustomizedAPIKey - clientID:nil - trackingID:nil - androidClientID:nil - databaseURL:nil - storageBucket:nil - deepLinkURLScheme:nil]; -#pragma clang diagnostic pop + // valid customized options + FIROptions *options = + [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + options.bundleID = kBundleID; + options.APIKey = kCustomizedAPIKey; NSDictionary *expectedUserInfo = [self expectedUserInfoWithAppName:kFIRDefaultAppName isDefaultApp:YES]; OCMExpect([self.notificationCenterMock postNotificationName:kFIRAppReadyToConfigureSDKNotification @@ -194,21 +184,11 @@ NSString *const kFIRTestAppName2 = @"test-app-name-2"; XCTAssertTrue([FIRApp allApps].count == 1); self.app = [FIRApp appNamed:kFIRTestAppName1]; -// Configure a different app with valid customized options -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnonnull" -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - FIROptions *customizedOptions = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID - bundleID:kBundleID - GCMSenderID:kGCMSenderID - APIKey:kCustomizedAPIKey - clientID:nil - trackingID:nil - androidClientID:nil - databaseURL:nil - storageBucket:nil - deepLinkURLScheme:nil]; -#pragma clang diagnostic pop + // Configure a different app with valid customized options + FIROptions *customizedOptions = + [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + customizedOptions.bundleID = kBundleID; + customizedOptions.APIKey = kCustomizedAPIKey; NSDictionary *expectedUserInfo2 = [self expectedUserInfoWithAppName:kFIRTestAppName2 isDefaultApp:NO]; diff --git a/Example/Core/Tests/FIROptionsTest.m b/Example/Core/Tests/FIROptionsTest.m index 5d66ca9..e4813f1 100644 --- a/Example/Core/Tests/FIROptionsTest.m +++ b/Example/Core/Tests/FIROptionsTest.m @@ -81,51 +81,20 @@ extern NSString *const kFIRLibraryVersionID; } - (void)testInitCustomizedOptions { -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID - bundleID:kBundleID - GCMSenderID:kGCMSenderID - APIKey:kAPIKey - clientID:kClientID - trackingID:kTrackingID - androidClientID:(id _Nonnull)nil - databaseURL:kDatabaseURL - storageBucket:kStorageBucket - deepLinkURLScheme:kDeepLinkURLScheme]; -#pragma clang pop - [self assertOptionsMatchDefaults:options andProjectID:NO]; - XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme); - XCTAssertFalse(options.usingOptionsFromDefaultPlist); - - FIROptions *options2 = + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; - options2.APIKey = kAPIKey; - options2.bundleID = kBundleID; - options2.clientID = kClientID; - options2.databaseURL = kDatabaseURL; - options2.deepLinkURLScheme = kDeepLinkURLScheme; - options2.projectID = kProjectID; - options2.storageBucket = kStorageBucket; - options2.trackingID = kTrackingID; - [self assertOptionsMatchDefaults:options2 andProjectID:YES]; - XCTAssertEqualObjects(options2.deepLinkURLScheme, kDeepLinkURLScheme); + options.androidClientID = kAndroidClientID; + options.APIKey = kAPIKey; + options.bundleID = kBundleID; + options.clientID = kClientID; + options.databaseURL = kDatabaseURL; + options.deepLinkURLScheme = kDeepLinkURLScheme; + options.projectID = kProjectID; + options.storageBucket = kStorageBucket; + options.trackingID = kTrackingID; + [self assertOptionsMatchDefaults:options andProjectID:YES]; + XCTAssertEqualObjects(options.deepLinkURLScheme, kDeepLinkURLScheme); XCTAssertFalse(options.usingOptionsFromDefaultPlist); - -// nil GoogleAppID should throw an exception -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnonnull" -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - XCTAssertThrows([[FIROptions alloc] initWithGoogleAppID:nil - bundleID:kBundleID - GCMSenderID:kGCMSenderID - APIKey:kCustomizedAPIKey - clientID:nil - trackingID:nil - androidClientID:nil - databaseURL:nil - storageBucket:nil - deepLinkURLScheme:nil]); -#pragma clang diagnostic pop } - (void)testInitWithContentsOfFile { @@ -239,16 +208,9 @@ extern NSString *const kFIRLibraryVersionID; XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme); // customized options - FIROptions *customizedOptions = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID - bundleID:kBundleID - GCMSenderID:kGCMSenderID - APIKey:kAPIKey - clientID:kClientID - trackingID:kTrackingID - androidClientID:(id _Nonnull)nil - databaseURL:kDatabaseURL - storageBucket:kStorageBucket - deepLinkURLScheme:kDeepLinkURLScheme]; + FIROptions *customizedOptions = + [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + customizedOptions.deepLinkURLScheme = kDeepLinkURLScheme; FIROptions *copyCustomizedOptions = [customizedOptions copy]; [copyCustomizedOptions setDeepLinkURLScheme:kNewDeepLinkURLScheme]; XCTAssertEqualObjects(customizedOptions.deepLinkURLScheme, kDeepLinkURLScheme); diff --git a/Firebase/Core/FIROptions.m b/Firebase/Core/FIROptions.m index b53fa52..56a56ff 100644 --- a/Firebase/Core/FIROptions.m +++ b/Firebase/Core/FIROptions.m @@ -194,45 +194,6 @@ static NSDictionary *sDefaultOptionsDictionary = nil; #pragma mark - Public instance methods -- (instancetype)initWithGoogleAppID:(NSString *)googleAppID - bundleID:(NSString *)bundleID - GCMSenderID:(NSString *)GCMSenderID - APIKey:(NSString *)APIKey - clientID:(NSString *)clientID - trackingID:(NSString *)trackingID - androidClientID:(NSString *)androidClientID - databaseURL:(NSString *)databaseURL - storageBucket:(NSString *)storageBucket - deepLinkURLScheme:(NSString *)deepLinkURLScheme { - self = [super init]; - if (self) { - if (!googleAppID) { - [NSException raise:kFirebaseCoreErrorDomain format:@"Please specify a valid Google App ID."]; - } else if (!GCMSenderID) { - [NSException raise:kFirebaseCoreErrorDomain format:@"Please specify a valid GCM Sender ID."]; - } - - // `bundleID` is a required property, default to the main `bundleIdentifier` if it's `nil`. - if (!bundleID) { - bundleID = [[NSBundle mainBundle] bundleIdentifier]; - } - - NSMutableDictionary *mutableOptionsDict = [NSMutableDictionary dictionary]; - [mutableOptionsDict setValue:googleAppID forKey:kFIRGoogleAppID]; - [mutableOptionsDict setValue:bundleID forKey:kFIRBundleID]; - [mutableOptionsDict setValue:GCMSenderID forKey:kFIRGCMSenderID]; - [mutableOptionsDict setValue:APIKey forKey:kFIRAPIKey]; - [mutableOptionsDict setValue:clientID forKey:kFIRClientID]; - [mutableOptionsDict setValue:trackingID forKey:kFIRTrackingID]; - [mutableOptionsDict setValue:androidClientID forKey:kFIRAndroidClientID]; - [mutableOptionsDict setValue:databaseURL forKey:kFIRDatabaseURL]; - [mutableOptionsDict setValue:storageBucket forKey:kFIRStorageBucket]; - self.optionsDictionary = mutableOptionsDict; - self.deepLinkURLScheme = deepLinkURLScheme; - } - return self; -} - - (instancetype)initWithContentsOfFile:(NSString *)plistPath { self = [super init]; if (self) { diff --git a/Firebase/Core/Public/FIROptions.h b/Firebase/Core/Public/FIROptions.h index b4e3b3b..87a01dd 100644 --- a/Firebase/Core/Public/FIROptions.h +++ b/Firebase/Core/Public/FIROptions.h @@ -91,25 +91,6 @@ NS_SWIFT_NAME(FirebaseOptions) @property(nonatomic, copy, nullable) NSString *storageBucket; /** - * Initializes a customized instance of FIROptions with keys. googleAppID, bundleID and GCMSenderID - * are required. Other keys may required for configuring specific services. - */ -- (instancetype)initWithGoogleAppID:(NSString *)googleAppID - bundleID:(NSString *)bundleID - GCMSenderID:(NSString *)GCMSenderID - APIKey:(NSString *)APIKey - clientID:(NSString *)clientID - trackingID:(NSString *)trackingID - androidClientID:(NSString *)androidClientID - databaseURL:(NSString *)databaseURL - storageBucket:(NSString *)storageBucket - deepLinkURLScheme:(NSString *)deepLinkURLScheme - DEPRECATED_MSG_ATTRIBUTE( - "Use `-[[FIROptions alloc] initWithGoogleAppID:GCMSenderID:]` " - "(`FirebaseOptions(googleAppID:gcmSenderID:)` in Swift)` and property " - "setters instead."); - -/** * Initializes a customized instance of FIROptions from the file at the given plist file path. This * will read the file synchronously from disk. * For example, |