diff --git a/Example/DynamicLinks/App/iOS/DL-Info.plist b/Example/DynamicLinks/App/iOS/DL-Info.plist index 755ff83d4c2..fc26896d71d 100644 --- a/Example/DynamicLinks/App/iOS/DL-Info.plist +++ b/Example/DynamicLinks/App/iOS/DL-Info.plist @@ -50,11 +50,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - FirebaseDynamicLinksCustomDomains - - https://google.com - https://google.com/one - https://a.firebase.com/mypath - diff --git a/Example/DynamicLinks/FDLBuilderTestAppObjC/Info.plist b/Example/DynamicLinks/FDLBuilderTestAppObjC/Info.plist index d1df0bfa0cb..ee3a448f005 100644 --- a/Example/DynamicLinks/FDLBuilderTestAppObjC/Info.plist +++ b/Example/DynamicLinks/FDLBuilderTestAppObjC/Info.plist @@ -2,20 +2,6 @@ - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 CFBundleURLTypes @@ -69,22 +55,22 @@ + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 CFBundleVersion 1 - FirebaseDynamicLinksCustomDomains - - https://mydomain.com - https://mydomain2.com - https://google.com - https://google.com - google - mydomain.com - https://mydomain - https://mydomain3.com - https://google.com/one - https://custom.com/one/two - https://custom1.com/one/ - LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m b/Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m index 51450db9b4c..cfacbc060ad 100644 --- a/Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m +++ b/Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m @@ -155,9 +155,9 @@ - (void)_initDefaultValues { }, // The default value of domain appcode belongs to project: app-invites-qa @{ - @"id" : @"domainURIPrefix", - @"label" : @"App domainURIPrefix (required)", - @"defaultValue" : @"https://testfdl.page.link", + @"id" : @"domain", + @"label" : @"App domain (required)", + @"defaultValue" : @"testfdl.page.link", }, // analytics params @{ @@ -289,8 +289,7 @@ - (void)_initDefaultValues { - (void)_buildFDLLink { NSURL *link = [NSURL URLWithString:_paramValues[@"linkString"]]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link - domainURIPrefix:_paramValues[@"https://domain"]]; + [FIRDynamicLinkComponents componentsWithLink:link domain:_paramValues[@"domain"]]; FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams = [FIRDynamicLinkGoogleAnalyticsParameters diff --git a/Example/DynamicLinks/FDLBuilderTestAppObjCTests/Info.plist b/Example/DynamicLinks/FDLBuilderTestAppObjCTests/Info.plist index 13fcbb5045d..6c6c23c43ad 100644 --- a/Example/DynamicLinks/FDLBuilderTestAppObjCTests/Info.plist +++ b/Example/DynamicLinks/FDLBuilderTestAppObjCTests/Info.plist @@ -18,24 +18,5 @@ 1.0 CFBundleVersion 1 - <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<array> - <string>https://mydomain.com</string> - <string>https://mydomain2.com</string> - <string>https://google.com</string> - <string>https://google.com</string> - <string>go</string> - <string>g.co</string> - <string>https://go</string> - <string>https://g.co</string> - <string>https://google.com/one</string> - <string>https://custom.com/one/two</string> - <string>https://custom1.com/one/</string> -</array> -</plist> - - diff --git a/Example/DynamicLinks/Tests/FDLURLComponentsTests.m b/Example/DynamicLinks/Tests/FDLURLComponentsTests.m index c7fa6f6bc8b..b1a51ee5f3b 100644 --- a/Example/DynamicLinks/Tests/FDLURLComponentsTests.m +++ b/Example/DynamicLinks/Tests/FDLURLComponentsTests.m @@ -21,8 +21,7 @@ #import -static NSString *const kFDLURLDomain = @"https://xyz.page.link"; -static NSString *const kFDLURLCustomDomain = @"https://foo.com/path"; +static NSString *const kFDLURLDomain = @"xyz.page.link"; @interface FDLURLComponentsTests : XCTestCase @end @@ -462,14 +461,14 @@ - (void)testLinkOptionsParamsPropertiesSetProperly { - (void)testFDLComponentsFactoryReturnsInstanceOfCorrectClass { NSURL *link = [NSURL URLWithString:@"https://google.com"]; - id returnValue = [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; + id returnValue = [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; XCTAssertTrue([returnValue isKindOfClass:[FIRDynamicLinkComponents class]]); } - (void)testFDLComponentsFactoryReturnsInstanceWithAllNilProperties { NSURL *link = [NSURL URLWithString:@"https://google.com"]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; + [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; XCTAssertNil(components.analyticsParameters); XCTAssertNil(components.socialMetaTagParameters); @@ -485,27 +484,11 @@ - (void)testFDLComponentsCreatesSimplestLinkCorrectly { NSURL *link = [NSURL URLWithString:linkString]; NSString *expectedURLString = - [NSString stringWithFormat:@"%@/?link=%@", kFDLURLDomain, endcodedLinkString]; + [NSString stringWithFormat:@"https://%@/?link=%@", kFDLURLDomain, endcodedLinkString]; NSURL *expectedURL = [NSURL URLWithString:expectedURLString]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; - NSURL *actualURL = components.url; - - XCTAssertEqualObjects(actualURL, expectedURL); -} - -- (void)testFDLComponentsCustomDomainWithPath { - NSString *linkString = @"https://google.com"; - NSString *endcodedLinkString = @"https%3A%2F%2Fgoogle%2Ecom"; - NSURL *link = [NSURL URLWithString:linkString]; - - NSString *expectedURLString = - [NSString stringWithFormat:@"%@/?link=%@", kFDLURLCustomDomain, endcodedLinkString]; - NSURL *expectedURL = [NSURL URLWithString:expectedURLString]; - - FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLCustomDomain]; + [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; NSURL *actualURL = components.url; XCTAssertEqualObjects(actualURL, expectedURL); @@ -516,8 +499,7 @@ - (void)testFDLComponentsFailsOnMalformedDomain { NSURL *link = [NSURL URLWithString:linkString]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link - domainURIPrefix:@"this is invalid domain URI Prefix"]; + [FIRDynamicLinkComponents componentsWithLink:link domain:@"this is invalid domain"]; XCTAssertNil(components.url); } @@ -571,7 +553,7 @@ - (void)testFDLComponentsCreatesFullLinkCorrectly { NSURL *link = [NSURL URLWithString:@"https://google.com"]; FIRDynamicLinkComponents *fdlComponents = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; + [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; fdlComponents.analyticsParameters = analyticsParams; fdlComponents.iOSParameters = iosParams; fdlComponents.iTunesConnectParameters = itcParams; @@ -660,43 +642,7 @@ - (void)testShortenURL { XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"]; NSURL *link = [NSURL URLWithString:@"https://google.com/abc"]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; - [components - shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, - NSError *_Nullable error) { - XCTAssertEqualObjects(shortURL.absoluteString, shortURLString); - [expectation fulfill]; - }]; - [self waitForExpectationsWithTimeout:0.1 handler:nil]; - - [keyProviderClassMock verify]; - [keyProviderClassMock stopMocking]; - [componentsClassMock verify]; - [componentsClassMock stopMocking]; -} - -- (void)testDeprecatedMethodComponentsWithLinkForDomain { - NSString *shortURLString = @"https://xyz.page.link/abcd"; - - // Mock key provider - id keyProviderClassMock = OCMClassMock([FIRDynamicLinkComponentsKeyProvider class]); - [[[keyProviderClassMock expect] andReturn:@"fake-api-key"] APIKey]; - - id componentsClassMock = OCMClassMock([FIRDynamicLinkComponents class]); - [[componentsClassMock expect] - sendHTTPRequest:OCMOCK_ANY - completion:[OCMArg checkWithBlock:^BOOL(id obj) { - void (^completion)(NSData *_Nullable, NSError *_Nullable) = obj; - NSDictionary *JSON = @{@"shortLink" : shortURLString}; - NSData *JSONData = [NSJSONSerialization dataWithJSONObject:JSON options:0 error:0]; - completion(JSONData, nil); - return YES; - }]]; - - XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"]; - NSURL *link = [NSURL URLWithString:@"https://google.com/abc"]; - FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domain:@"xyz.page.link"]; + [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; [components shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, NSError *_Nullable error) { @@ -733,7 +679,7 @@ - (void)testShortenURLReturnsErrorWhenAPIKeyMissing { [self expectationWithDescription:@"completion called with error"]; NSURL *link = [NSURL URLWithString:@"https://google.com/abc"]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain]; + [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain]; [components shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, NSError *_Nullable error) { @@ -768,11 +714,20 @@ - (void)testShortenURLReturnsErrorWhenDomainIsMalformed { return YES; }]]; + XCTestExpectation *expectation = + [self expectationWithDescription:@"completion called with error"]; NSURL *link = [NSURL URLWithString:@"https://google.com/abc"]; FIRDynamicLinkComponents *components = - [FIRDynamicLinkComponents componentsWithLink:link - domainURIPrefix:@"this is invalid domain URI Prefix"]; - XCTAssertNil(components); + [FIRDynamicLinkComponents componentsWithLink:link domain:@"this is invalid domain"]; + [components + shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray *_Nullable warnings, + NSError *_Nullable error) { + XCTAssertNil(shortURL); + if (error) { + [expectation fulfill]; + } + }]; + [self waitForExpectationsWithTimeout:0.1 handler:nil]; [keyProviderClassMock verify]; [keyProviderClassMock stopMocking]; diff --git a/Example/DynamicLinks/Tests/FIRDynamicLinkNetworkingTests.m b/Example/DynamicLinks/Tests/FIRDynamicLinkNetworkingTests.m index 80be311184e..3a8070e2c49 100644 --- a/Example/DynamicLinks/Tests/FIRDynamicLinkNetworkingTests.m +++ b/Example/DynamicLinks/Tests/FIRDynamicLinkNetworkingTests.m @@ -16,7 +16,7 @@ #import -#import +#import "OCMock.h" #import #import "DynamicLinks/FIRDynamicLinkNetworking+Private.h" diff --git a/Example/DynamicLinks/Tests/FIRDynamicLinksTest.m b/Example/DynamicLinks/Tests/FIRDynamicLinksTest.m index c9ed77c5bdb..8dbb0e9a32d 100644 --- a/Example/DynamicLinks/Tests/FIRDynamicLinksTest.m +++ b/Example/DynamicLinks/Tests/FIRDynamicLinksTest.m @@ -1015,57 +1015,6 @@ - (void)testSelfDiagnoseCompletionCalled { [self waitForExpectationsWithTimeout:2.0 handler:nil]; } -#pragma mark - Custom domain tests -- (void)testValidCustomDomainNames { - // Entries in plist file: - // https://google.com - // https://google.com/one - // https://a.firebase.com/mypath - - NSArray *urlStrings = @[ - @"https://google.com/1", // Valid domain. Any path. - @"https://google.com/2", // Valid domain. Any path. - @"https://google.com/one", // Valid domain. Specified path. - @"https://a.firebase.com/mypath/", // Valid subdomain. - @"https://a.firebase.com/mypath/abcd/efgh", // Long path. - @"https://a.firebase.com/mypath?link=abcd&test=1", // Long path. - ]; - - for (NSString *urlString in urlStrings) { - NSURL *url = [NSURL URLWithString:urlString]; - BOOL matchesShortLinkFormat = [self.service matchesShortLinkFormat:url]; - - XCTAssertTrue(matchesShortLinkFormat, - @"Non-DDL domain URL matched short link format with URL: %@", url); - } -} - -- (void)testInvalidCustomDomainNames { - // Entries in plist file: - // https://google.com - // https://google.com/one - // https://a.firebase.com/mypath - - NSArray *urlStrings = @[ - @"mydomain.com", // Domain not in plist. Also, no scheme. - @"http://mydomain", // Domain not in plist. No path. - @"google.com", // Valid domain. No scheme. - @"https://google.com", // Valid domain. No path. - @"http://google.com", // Valid domain. Invalid scheme. - @"https://google.co.in/abc", // Invalid domain starts with valid domain name. - @"https://firebase.com/mypath", // Invalid (sub)domain. - @"https://b.firebase.com/mypath" // Invalid subdomain. - ]; - - for (NSString *urlString in urlStrings) { - NSURL *url = [NSURL URLWithString:urlString]; - BOOL matchesShortLinkFormat = [self.service matchesShortLinkFormat:url]; - - XCTAssertFalse(matchesShortLinkFormat, - @"Non-DDL domain URL matched short link format with URL: %@", url); - } -} - #pragma mark - Private Helpers - (void)removeAllFIRApps { diff --git a/Firebase/DynamicLinks/CHANGELOG.md b/Firebase/DynamicLinks/CHANGELOG.md index 79655c21b1b..48c29fe0237 100644 --- a/Firebase/DynamicLinks/CHANGELOG.md +++ b/Firebase/DynamicLinks/CHANGELOG.md @@ -1,5 +1,4 @@ # v3.2.0 -- Add support for creating and receiving dynamic links from custom domains. This feature is not yet available for public consumption. (#1962, #2017, #2078) - Delete deprecated source files. (#2038) # v3.1.1 diff --git a/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m b/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m index 2fe4323bbba..9c6a0062ae0 100644 --- a/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m +++ b/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m @@ -20,7 +20,6 @@ #import "DynamicLinks/FDLURLComponents/FIRDynamicLinkComponentsKeyProvider.h" #import "DynamicLinks/Public/FDLURLComponents.h" -#import "DynamicLinks/Logging/FDLLogging.h" #import "DynamicLinks/Utilities/FDLUtilities.h" /// The exact behavior of dict[key] = value is unclear when value is nil. This function safely adds @@ -449,62 +448,15 @@ - (instancetype)init { @implementation FIRDynamicLinkComponents -#pragma mark Deprecated Initializers. + (instancetype)componentsWithLink:(NSURL *)link domain:(NSString *)domain { - NSURL *domainURL = [NSURL URLWithString:domain]; - if (!domainURL.scheme) { - FDLLog(FDLLogLevelWarning, FDLLogIdentifierSetupWarnHTTPSScheme, - @"Only https scheme is allowed. The supplied domain's scheme will be treated as https."); - } - NSString *domainURIPrefix = - domainURL.scheme ? domain : [NSString stringWithFormat:@"https://%@", domain]; - return [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:domainURIPrefix]; + return [[self alloc] initWithLink:link domain:domain]; } - (instancetype)initWithLink:(NSURL *)link domain:(NSString *)domain { - NSURL *domainURL = [NSURL URLWithString:domain]; - if (!domainURL.scheme) { - FDLLog(FDLLogLevelWarning, FDLLogIdentifierSetupWarnHTTPSScheme, - @"Only https scheme is allowed. The supplied domain's scheme will be treated as https."); - } - NSString *domainURIPrefix = - domainURL.scheme ? domain : [NSString stringWithFormat:@"https://%@", domain]; - return [self initWithLink:link domainURIPrefix:domainURIPrefix]; -} - -#pragma mark Initializers. -+ (instancetype)componentsWithLink:(NSURL *)link domainURIPrefix:(NSString *)domainURIPrefix { - NSURL *domainURIPrefixURL = [NSURL URLWithString:domainURIPrefix]; - if (!domainURIPrefixURL) { - FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefix, - @"Invalid domainURIPrefix. Please input a valid URL."); - return nil; - } - if (![[domainURIPrefixURL.scheme lowercaseString] isEqualToString:@"https"]) { - FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefixScheme, - @"Invalid domainURIPrefix scheme. Scheme needs to be https"); - return nil; - } - return [[self alloc] initWithLink:link domainURIPrefix:domainURIPrefix]; -} - -- (instancetype)initWithLink:(NSURL *)link domainURIPrefix:(NSString *)domainURIPrefix { self = [super init]; if (self) { _link = link; - /// Must be a URL that conforms to RFC 2396. - NSURL *domainURIPrefixURL = [NSURL URLWithString:domainURIPrefix]; - if (!domainURIPrefixURL) { - FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefix, - @"Invalid domainURIPrefix. Please input a valid URL."); - return nil; - } - if (![[domainURIPrefixURL.scheme lowercaseString] isEqualToString:@"https"]) { - FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefixScheme, - @"Invalid domainURIPrefix scheme. Scheme needs to be https"); - return nil; - } - _domain = [domainURIPrefix copy]; + _domain = [domain copy]; } return self; } @@ -641,7 +593,7 @@ - (NSURL *)url { addEntriesFromDictionaryRepresentingConformerToDictionary(_otherPlatformParameters); NSString *queryString = FIRDLURLQueryStringFromDictionary(queryDictionary); - NSString *urlString = [NSString stringWithFormat:@"%@/%@", _domain, queryString]; + NSString *urlString = [NSString stringWithFormat:@"https://%@/%@", _domain, queryString]; return [NSURL URLWithString:urlString]; } diff --git a/Firebase/DynamicLinks/FIRDynamicLinks.m b/Firebase/DynamicLinks/FIRDynamicLinks.m index 0dacdd8b93e..f12c0ed84c0 100644 --- a/Firebase/DynamicLinks/FIRDynamicLinks.m +++ b/Firebase/DynamicLinks/FIRDynamicLinks.m @@ -60,9 +60,6 @@ // We should only open url once. We use the following key to store the state in the user defaults. static NSString *const kFIRDLOpenURLKey = @"com.google.appinvite.openURL"; -// Custom domains to be whitelisted are optionally added as an array to the info.plist. -static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustomDomains"; - NS_ASSUME_NONNULL_BEGIN @interface FIRDynamicLinks () @@ -219,12 +216,6 @@ - (void)configureDynamicLinks:(FIRApp *)app { } [NSException raise:kFirebaseDurableDeepLinkErrorDomain format:@"%@", message]; } - // Check to see if FirebaseDynamicLinksCustomDomains array is present. - NSDictionary *infoDictionary = [NSBundle mainBundle].infoDictionary; - NSArray *customDomains = infoDictionary[kInfoPlistCustomDomainsKey]; - if (customDomains) { - FIRDLAddToWhiteListForCustomDomainsArray(customDomains); - } } - (instancetype)initWithAnalytics:(nullable id)analytics { diff --git a/Firebase/DynamicLinks/Logging/FDLLogging.h b/Firebase/DynamicLinks/Logging/FDLLogging.h index 2d0efc572e2..5a9ea134d47 100644 --- a/Firebase/DynamicLinks/Logging/FDLLogging.h +++ b/Firebase/DynamicLinks/Logging/FDLLogging.h @@ -33,9 +33,6 @@ typedef NS_ENUM(NSInteger, FDLLogIdentifier) { FDLLogIdentifierSetupNilAPIKey = 0, FDLLogIdentifierSetupNilClientID = 1, FDLLogIdentifierSetupNonDefaultApp = 2, - FDLLogIdentifierSetupInvalidDomainURIPrefixScheme = 3, - FDLLogIdentifierSetupInvalidDomainURIPrefix = 4, - FDLLogIdentifierSetupWarnHTTPSScheme = 5, }; /** The appropriate formatter for using NSInteger in FIRLogger. */ diff --git a/Firebase/DynamicLinks/Public/FDLURLComponents.h b/Firebase/DynamicLinks/Public/FDLURLComponents.h index a06dc5a1585..cc27736f545 100644 --- a/Firebase/DynamicLinks/Public/FDLURLComponents.h +++ b/Firebase/DynamicLinks/Public/FDLURLComponents.h @@ -512,14 +512,11 @@ FIR_SWIFT_NAME(DynamicLinkComponents) * @param link Deep link to be stored in created Dynamic link. This link also called "payload" of * the Dynamic link. * @param domain Domain of your App. This value must be equal to your assigned domain from Firebase - * Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is - * assumed as such by this API. + * Console. */ + (instancetype)componentsWithLink:(NSURL *)link domain:(NSString *)domain - NS_SWIFT_UNAVAILABLE("Use init(link:domain:)")DEPRECATED_MSG_ATTRIBUTE( - "This method is deprecated. Please use the new method with support for " - "domainURIPrefix- componentsWithLink:domainURIPrefix."); + NS_SWIFT_UNAVAILABLE("Use init(link:domain:)"); /** * @method initWithLink:domain: @@ -528,42 +525,9 @@ FIR_SWIFT_NAME(DynamicLinkComponents) * @param link Deep link to be stored in created Dynamic link. This link also called "payload" of * the Dynamic link. * @param domain Domain of your App. This value must be equal to your assigned domain from Firebase - * Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is - * assumed as such by this API. + * Console. */ -- (instancetype)initWithLink:(NSURL *)link - domain:(NSString *)domain - DEPRECATED_MSG_ATTRIBUTE( - "This method is deprecated. Please use the new method with support for " - "domainURIPrefix- initWithLink:domainURIPrefix."); - -/** - * @method componentsWithLink:domain: - * @abstract Generates a Dynamic Link URL components object with the minimum necessary parameters - * set to generate a fully-functional Dynamic Link. - * @param link Deep link to be stored in created Dynamic link. This link also called "payload" of - * the Dynamic link. - * @param domainURIPrefix Domain URI Prefix of your App. This value must be either a. your assigned - * domain from the Firebase console or b. your custom domain or c. your custom domain with a valid - * path that is registered for Dynamic Links. The domain URI prefix must start with a valid scheme - * (https://) - */ -+ (instancetype)componentsWithLink:(NSURL *)link - domainURIPrefix:(NSString *)domainURIPrefix - NS_SWIFT_UNAVAILABLE("Use init(link:domainURIPrefix:)"); - -/** - * @method initWithLink:domain: - * @abstract Generates a Dynamic Link URL components object with the minimum necessary parameters - * set to generate a fully-functional Dynamic Link. - * @param link Deep link to be stored in created Dynamic link. This link also called "payload" of - * the Dynamic link. - * @param domainURIPrefix Domain URI Prefix of your App. This value must be either a. your assigned - * domain from the Firebase console or b. your custom domain or c. your custom domain with a valid - * path that is registered for Dynamic Links. The domain URI prefix must start with a valid scheme - * (https://). - */ -- (instancetype)initWithLink:(NSURL *)link domainURIPrefix:(NSString *)domainURIPrefix; +- (instancetype)initWithLink:(NSURL *)link domain:(NSString *)domain; /** * @method shortenURL:options:completion: diff --git a/Firebase/DynamicLinks/Utilities/FDLUtilities.h b/Firebase/DynamicLinks/Utilities/FDLUtilities.h index 63c570e3d20..1aa664f136f 100644 --- a/Firebase/DynamicLinks/Utilities/FDLUtilities.h +++ b/Firebase/DynamicLinks/Utilities/FDLUtilities.h @@ -136,9 +136,4 @@ BOOL FIRDLMatchesShortLinkFormat(NSURL *URL); */ NSString *FIRDLMatchTypeStringFromServerString(NSString *_Nullable serverMatchTypeString); -/** - Add custom domains from the info.plist to the internal whitelist. - */ -void FIRDLAddToWhiteListForCustomDomainsArray(NSArray *_Nonnull customDomains); - NS_ASSUME_NONNULL_END diff --git a/Firebase/DynamicLinks/Utilities/FDLUtilities.m b/Firebase/DynamicLinks/Utilities/FDLUtilities.m index 8217bb489e8..425e2a52909 100644 --- a/Firebase/DynamicLinks/Utilities/FDLUtilities.m +++ b/Firebase/DynamicLinks/Utilities/FDLUtilities.m @@ -32,7 +32,6 @@ NSString *const kFIRDLParameterWeakMatchEndpoint = @"invitation_weakMatchEndpoint"; NSString *const kFIRDLParameterMatchMessage = @"match_message"; NSString *const kFIRDLParameterRequestIPVersion = @"request_ip_version"; -static NSSet *FIRDLCustomDomains = nil; NSURL *FIRDLCookieRetrievalURL(NSString *urlScheme, NSString *bundleID) { static NSString *const kFDLBundleIDQueryParameterName = @"fdl_ios_bundle_id"; @@ -193,23 +192,6 @@ BOOL FIRDLOSVersionSupported(NSString *_Nullable systemVersion, NSString *minSup return timeZoneName; } -BOOL FIRDLIsURLForWhiteListedCustomDomain(NSURL *_Nullable URL) { - BOOL customDomainMatchFound = false; - for (NSURL *allowedCustomDomain in FIRDLCustomDomains) { - // All custom domain host names should match at a minimum. - if ([allowedCustomDomain.host isEqualToString:URL.host]) { - // Next, do a string compare to check if the full path matches as well. - if (([URL.absoluteString rangeOfString:allowedCustomDomain.absoluteString - options:NSCaseInsensitiveSearch | NSAnchoredSearch] - .location) == 0) { - customDomainMatchFound = true; - break; - } - } - } - return customDomainMatchFound; -} - BOOL FIRDLCanParseUniversalLinkURL(NSURL *_Nullable URL) { // Handle universal links with format |https://goo.gl/app/?|. // Also support page.link format. @@ -218,11 +200,7 @@ BOOL FIRDLCanParseUniversalLinkURL(NSURL *_Nullable URL) { // Handle universal links with format |https://.app.goo.gl?| and page.link. BOOL isDDLWithSubdomain = [URL.host hasSuffix:@".app.goo.gl"] || [URL.host hasSuffix:@".page.link"]; - - // Handle universal links for custom domains. - BOOL isDDLWithCustomDomain = FIRDLIsURLForWhiteListedCustomDomain(URL); - - return isDDLWithAppcodeInPath || isDDLWithSubdomain || isDDLWithCustomDomain; + return isDDLWithAppcodeInPath || isDDLWithSubdomain; } BOOL FIRDLMatchesShortLinkFormat(NSURL *URL) { @@ -249,19 +227,4 @@ BOOL FIRDLMatchesShortLinkFormat(NSURL *URL) { return matchMap[serverMatchTypeString] ?: @"none"; } -void FIRDLAddToWhiteListForCustomDomainsArray(NSArray *_Nonnull customDomains) { - // Duplicates will be weeded out when converting to a set. - NSMutableArray *validCustomDomains = - [[NSMutableArray alloc] initWithCapacity:customDomains.count]; - for (NSString *customDomainEntry in customDomains) { - NSURL *customDomainURL = [NSURL URLWithString:customDomainEntry]; - // We require a valid scheme for each custom domain enumerated in the info.plist file. - if (customDomainURL && customDomainURL.scheme) { - [validCustomDomains addObject:customDomainURL]; - } - } - // Duplicates will be weeded out when converting to a set. - FIRDLCustomDomains = [NSSet setWithArray:validCustomDomains]; -} - NS_ASSUME_NONNULL_END