Make iOS embedding to send full uri for deeplinks (flutter/engine#41992)

related https://github.com/flutter/flutter/issues/100624

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
chunhtai
2023-05-18 13:31:17 -07:00
committed by GitHub
parent 0c46b09bbf
commit d21dc12d2f
2 changed files with 11 additions and 15 deletions

View File

@@ -150,17 +150,10 @@ static NSString* const kRestorationStateAppModificationKey = @"mod-date";
FML_LOG(ERROR) FML_LOG(ERROR)
<< "Timeout waiting for the first frame when launching an URL."; << "Timeout waiting for the first frame when launching an URL.";
} else { } 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 [flutterViewController.engine.navigationChannel
invokeMethod:@"pushRouteInformation" invokeMethod:@"pushRouteInformation"
arguments:@{ arguments:@{
@"location" : fullRoute, @"location" : url.absoluteString,
}]; }];
} }
}]; }];

View File

@@ -67,8 +67,9 @@ FLUTTER_ASSERT_ARC
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"] openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
options:@{}]; options:@{}];
XCTAssertTrue(result); XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation" OCMVerify([self.mockNavigationChannel
arguments:@{@"location" : @"/custom/route?query=test"}]); invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
} }
- (void)testLaunchUrlWithDeepLinkingNotSet { - (void)testLaunchUrlWithDeepLinkingNotSet {
@@ -106,7 +107,7 @@ FLUTTER_ASSERT_ARC
XCTAssertTrue(result); XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation" invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"/custom/route?query=test#fragment"}]); arguments:@{@"location" : @"http://myApp/custom/route?query=test#fragment"}]);
} }
- (void)testLaunchUrlWithFragmentNoQueryParameter { - (void)testLaunchUrlWithFragmentNoQueryParameter {
@@ -118,8 +119,9 @@ FLUTTER_ASSERT_ARC
openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"] openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
options:@{}]; options:@{}];
XCTAssertTrue(result); XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation" OCMVerify([self.mockNavigationChannel
arguments:@{@"location" : @"/custom/route#fragment"}]); invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route#fragment"}]);
} }
- (void)testReleasesWindowOnDealloc { - (void)testReleasesWindowOnDealloc {
@@ -152,8 +154,9 @@ FLUTTER_ASSERT_ARC
restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){ restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
}]; }];
XCTAssertTrue(result); XCTAssertTrue(result);
OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation" OCMVerify([self.mockNavigationChannel
arguments:@{@"location" : @"/custom/route?query=test"}]); invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
} }
@end @end