|
|
@@ -894,6 +894,63 @@ static NSString *const kInfoPlistCustomDomainsKey = @"FirebaseDynamicLinksCustom
|
|
|
XCTAssertEqualObjects(expectedMinVersion, minVersion, @"Min version didn't match imv= parameter");
|
|
|
}
|
|
|
|
|
|
+- (void)testDynamicLinkFromUniversalLinkURLReturnsUTMParams {
|
|
|
+ NSString *expectedUtmSource = @"utm_source";
|
|
|
+ NSString *expectedUtmMedium = @"utm_medium";
|
|
|
+ NSString *expectedUtmCampaign = @"utm_campaign";
|
|
|
+ NSString *expectedUtmTerm = @"utm_term";
|
|
|
+ NSString *expectedUtmContent = @"utm_content";
|
|
|
+
|
|
|
+ NSString *utmParamsString = [NSString
|
|
|
+ stringWithFormat:@"utm_source=%@&utm_medium=%@&utm_campaign=%@&utm_term=%@&utm_content=%@",
|
|
|
+ expectedUtmSource, expectedUtmMedium, expectedUtmCampaign, expectedUtmTerm,
|
|
|
+ expectedUtmContent];
|
|
|
+ NSString *urlSuffix =
|
|
|
+ [NSString stringWithFormat:@"%@&%@", kEncodedComplicatedURLString, utmParamsString];
|
|
|
+
|
|
|
+ NSString *urlString =
|
|
|
+ [NSString stringWithFormat:kStructuredUniversalLinkFmtSubdomainDeepLink, urlSuffix];
|
|
|
+ NSURL *url = [NSURL URLWithString:urlString];
|
|
|
+
|
|
|
+ [self.service setUpWithLaunchOptions:nil
|
|
|
+ apiKey:kAPIKey
|
|
|
+ urlScheme:kURLScheme
|
|
|
+ userDefaults:self.userDefaults];
|
|
|
+ XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
|
|
|
+ [self.service
|
|
|
+ dynamicLinkFromUniversalLinkURL:url
|
|
|
+ completion:^(FIRDynamicLink *_Nullable dynamicLink,
|
|
|
+ NSError *_Nullable error) {
|
|
|
+ XCTAssertTrue([NSThread isMainThread]);
|
|
|
+ NSDictionary *utmParameters = dynamicLink.utmParametersDictionary;
|
|
|
+ NSString *utmSource = [utmParameters objectForKey:@"utm_source"];
|
|
|
+ XCTAssertEqualObjects(utmSource, expectedUtmSource,
|
|
|
+ @"UtmSource doesn't match utm_source parameter");
|
|
|
+
|
|
|
+ NSString *utmMedium = [utmParameters objectForKey:@"utm_medium"];
|
|
|
+ XCTAssertEqualObjects(utmMedium, expectedUtmMedium,
|
|
|
+ @"UtmMedium doesn't match utm_medium parameter");
|
|
|
+
|
|
|
+ NSString *utmCampaign = [utmParameters objectForKey:@"utm_campaign"];
|
|
|
+ XCTAssertEqualObjects(
|
|
|
+ utmCampaign, expectedUtmCampaign,
|
|
|
+ @"UtmCampaign doesn't match utm_campaign parameter");
|
|
|
+
|
|
|
+ NSString *utmTerm = [utmParameters objectForKey:@"utm_term"];
|
|
|
+ XCTAssertEqualObjects(utmTerm, expectedUtmTerm,
|
|
|
+ @"UtmTerm doesn't match utm_term parameter");
|
|
|
+
|
|
|
+ NSString *utmContent = [utmParameters objectForKey:@"utm_content"];
|
|
|
+ XCTAssertEqualObjects(
|
|
|
+ utmContent, expectedUtmContent,
|
|
|
+ @"UtmContent doesn't match utm_content parameter");
|
|
|
+
|
|
|
+ [expectation fulfill];
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self waitForExpectationsWithTimeout:kAsyncTestTimout handler:nil];
|
|
|
+}
|
|
|
+
|
|
|
- (void)testDynamicLinkFromUniversalLinkURLCompletionReturnsDLMinimumVersion {
|
|
|
NSString *expectedMinVersion = @"03-9g03hfd";
|
|
|
NSString *urlSuffix =
|