Skip to content

Commit 863aec2

Browse files
dmandarCorrob
authored andcommitted
Remove deprecated API in FDLURLComponents. (#2768)
* Remove deprecated API in FDLURLComponents. * Fix style.
1 parent 6c71c07 commit 863aec2

File tree

2 files changed

+4
-110
lines changed

2 files changed

+4
-110
lines changed

Example/DynamicLinks/Tests/FDLURLComponentsTests.m

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ - (void)testFDLComponentsNotNilOnDomainWithHTTPScheme {
528528
NSURL *link = [NSURL URLWithString:linkString];
529529

530530
FIRDynamicLinkComponents *components =
531-
[FIRDynamicLinkComponents componentsWithLink:link domain:@"http://xyz.page.link"];
531+
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:@"https://xyz.page.link"];
532532

533533
XCTAssertNotNil(components);
534534
}
@@ -538,7 +538,7 @@ - (void)testFDLComponentsNotNilOnDomainWithHTTPSScheme {
538538
NSURL *link = [NSURL URLWithString:linkString];
539539

540540
FIRDynamicLinkComponents *components =
541-
[FIRDynamicLinkComponents componentsWithLink:link domain:@"https://xyz.page.link"];
541+
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:@"https://xyz.page.link"];
542542

543543
XCTAssertNotNil(components);
544544
}
@@ -549,10 +549,9 @@ - (void)testFDLComponentsFailsOnMalformedDomain {
549549

550550
FIRDynamicLinkComponents *components =
551551
[FIRDynamicLinkComponents componentsWithLink:link
552-
domain:@"this is invalid domain URI Prefix"];
552+
domainURIPrefix:@"this is invalid domain URI Prefix"];
553553

554-
XCTAssertNotNil(components);
555-
XCTAssertNil(components.url);
554+
XCTAssertNil(components);
556555
}
557556

558557
- (void)testFDLComponentsCreatesFullLinkCorrectly {
@@ -708,79 +707,6 @@ - (void)testShortenURL {
708707
[componentsClassMock stopMocking];
709708
}
710709

711-
- (void)testDeprecatedMethodComponentsWithLinkForDomain {
712-
NSString *shortURLString = @"https://xyz.page.link/abcd";
713-
714-
// Mock key provider
715-
id keyProviderClassMock = OCMClassMock([FIRDynamicLinkComponentsKeyProvider class]);
716-
[[[keyProviderClassMock expect] andReturn:@"fake-api-key"] APIKey];
717-
718-
id componentsClassMock = OCMClassMock([FIRDynamicLinkComponents class]);
719-
[[componentsClassMock expect]
720-
sendHTTPRequest:OCMOCK_ANY
721-
completion:[OCMArg checkWithBlock:^BOOL(id obj) {
722-
void (^completion)(NSData *_Nullable, NSError *_Nullable) = obj;
723-
NSDictionary *JSON = @{@"shortLink" : shortURLString};
724-
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:JSON options:0 error:0];
725-
completion(JSONData, nil);
726-
return YES;
727-
}]];
728-
729-
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
730-
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
731-
FIRDynamicLinkComponents *components =
732-
[FIRDynamicLinkComponents componentsWithLink:link domain:@"xyz.page.link"];
733-
[components
734-
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
735-
NSError *_Nullable error) {
736-
XCTAssertEqualObjects(shortURL.absoluteString, shortURLString);
737-
[expectation fulfill];
738-
}];
739-
[self waitForExpectationsWithTimeout:0.1 handler:nil];
740-
741-
[keyProviderClassMock verify];
742-
[keyProviderClassMock stopMocking];
743-
[componentsClassMock verify];
744-
[componentsClassMock stopMocking];
745-
}
746-
747-
- (void)testDeprecatedMethodComponentsWithLinkForDomainWithInvalidDomainScheme {
748-
NSString *shortURLString = @"https://xyz.page.link/abcd";
749-
750-
// Mock key provider
751-
id keyProviderClassMock = OCMClassMock([FIRDynamicLinkComponentsKeyProvider class]);
752-
[[[keyProviderClassMock expect] andReturn:@"fake-api-key"] APIKey];
753-
754-
id componentsClassMock = OCMClassMock([FIRDynamicLinkComponents class]);
755-
[[componentsClassMock expect]
756-
sendHTTPRequest:OCMOCK_ANY
757-
completion:[OCMArg checkWithBlock:^BOOL(id obj) {
758-
void (^completion)(NSData *_Nullable, NSError *_Nullable) = obj;
759-
NSDictionary *JSON = @{@"shortLink" : shortURLString};
760-
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:JSON options:0 error:0];
761-
completion(JSONData, nil);
762-
return YES;
763-
}]];
764-
765-
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
766-
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
767-
FIRDynamicLinkComponents *components =
768-
[FIRDynamicLinkComponents componentsWithLink:link domain:@"http://xyz.page.link"];
769-
XCTAssertNotNil(components);
770-
[components
771-
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
772-
NSError *_Nullable error) {
773-
XCTAssertEqualObjects(shortURL.absoluteString, shortURLString);
774-
[expectation fulfill];
775-
}];
776-
[self waitForExpectationsWithTimeout:0.1 handler:nil];
777-
778-
[keyProviderClassMock verify];
779-
[keyProviderClassMock stopMocking];
780-
[componentsClassMock verify];
781-
[componentsClassMock stopMocking];
782-
}
783-
784710
- (void)testShortenURLReturnsErrorWhenAPIKeyMissing {
785711
NSString *shortURLString = @"https://xyz.page.link/abcd";
786712

Firebase/DynamicLinks/Public/FDLURLComponents.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -505,38 +505,6 @@ FIR_SWIFT_NAME(DynamicLinkComponents)
505505
*/
506506
@property(nonatomic, nullable, readonly) NSURL *url;
507507

508-
/**
509-
* @method componentsWithLink:domain:
510-
* @abstract Generates a Dynamic Link URL components object with the minimum necessary parameters
511-
* set to generate a fully-functional Dynamic Link.
512-
* @param link Deep link to be stored in created Dynamic link. This link also called "payload" of
513-
* the Dynamic link.
514-
* @param domain Domain of your App. This value must be equal to your assigned domain from Firebase
515-
* Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is
516-
* assumed as such by this API.
517-
*/
518-
+ (instancetype)componentsWithLink:(NSURL *)link
519-
domain:(NSString *)domain
520-
NS_SWIFT_UNAVAILABLE("Use init(link:domain:)")DEPRECATED_MSG_ATTRIBUTE(
521-
"This method is deprecated. Please use the new method with support for "
522-
"domainURIPrefix- init(link:domainURIPrefix:).");
523-
524-
/**
525-
* @method initWithLink:domain:
526-
* @abstract Generates a Dynamic Link URL components object with the minimum necessary parameters
527-
* set to generate a fully-functional Dynamic Link.
528-
* @param link Deep link to be stored in created Dynamic link. This link also called "payload" of
529-
* the Dynamic link.
530-
* @param domain Domain of your App. This value must be equal to your assigned domain from Firebase
531-
* Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is
532-
* assumed as such by this API.
533-
*/
534-
- (instancetype)initWithLink:(NSURL *)link
535-
domain:(NSString *)domain
536-
DEPRECATED_MSG_ATTRIBUTE(
537-
"This method is deprecated. Please use the new method with support for "
538-
"domainURIPrefix- init(link:domainURIPrefix:).");
539-
540508
/**
541509
* @method componentsWithLink:domainURIPrefix:
542510
* @abstract Generates a Dynamic Link URL components object with the minimum necessary parameters

0 commit comments

Comments
 (0)