Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Make iOS embedding to send full uri for deeplinks #41992

Merged
merged 4 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,10 @@ - (BOOL)openURL:(NSURL*)url {
FML_LOG(ERROR)
<< "Timeout waiting for the first frame when launching an URL.";
} else {
NSString* fullRoute = url.path;
if ([url.query length] != 0) {
fullRoute = [NSString stringWithFormat:@"%@?%@", fullRoute, url.query];
}
if ([url.fragment length] != 0) {
fullRoute = [NSString stringWithFormat:@"%@#%@", fullRoute, url.fragment];
}
[flutterViewController.engine.navigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{
@"location" : fullRoute,
@"location" : url.absoluteString,
}];
}
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ - (void)testLaunchUrl {
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
options:@{}];
XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"/custom/route?query=test"}]);
OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it weird to be using the "http" protocol for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An universal link is either a http or https protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the framework pr flutter/flutter#119968, it just surface whatever url that is sent here to the developer in RouteInformation.url

The goal is to let developer to be able to handle differently based on what uri to launch the app, for example they may want to block certain route if the app is launch from example.com but not when it is launch from another-example.com

}

- (void)testLaunchUrlWithDeepLinkingNotSet {
Expand Down Expand Up @@ -106,7 +107,7 @@ - (void)testLaunchUrlWithQueryParameterAndFragment {
XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"/custom/route?query=test#fragment"}]);
arguments:@{@"location" : @"http://myApp/custom/route?query=test#fragment"}]);
}

- (void)testLaunchUrlWithFragmentNoQueryParameter {
Expand All @@ -118,8 +119,9 @@ - (void)testLaunchUrlWithFragmentNoQueryParameter {
openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
options:@{}];
XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"/custom/route#fragment"}]);
OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route#fragment"}]);
}

- (void)testReleasesWindowOnDealloc {
Expand Down Expand Up @@ -152,8 +154,9 @@ - (void)testUniversalLinkPushRouteInformation {
restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
}];
XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"/custom/route?query=test"}]);
OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
}

@end