From d21dc12d2f6fce28255c7fbecf6d2dca2b2da5d3 Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Thu, 18 May 2023 13:31:17 -0700 Subject: [PATCH] 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 --- .../ios/framework/Source/FlutterAppDelegate.mm | 9 +-------- .../framework/Source/FlutterAppDelegateTest.mm | 17 ++++++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm index abc1bd8e6b7..741a0bf626c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm @@ -150,17 +150,10 @@ static NSString* const kRestorationStateAppModificationKey = @"mod-date"; 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, }]; } }]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm index 035b726188d..81b93f0a8ff 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm @@ -67,8 +67,9 @@ FLUTTER_ASSERT_ARC 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"}]); } - (void)testLaunchUrlWithDeepLinkingNotSet { @@ -106,7 +107,7 @@ FLUTTER_ASSERT_ARC 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 { @@ -118,8 +119,9 @@ FLUTTER_ASSERT_ARC 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 { @@ -152,8 +154,9 @@ FLUTTER_ASSERT_ARC restorationHandler:^(NSArray>* __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