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 e23d61dcca..c4ef0790cb 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 @@ -164,7 +164,9 @@ static NSString* const kRestorationStateAppModificationKey = @"mod-date"; completionHandler:^(BOOL success) { if (!success && throwBack) { // throw it back to iOS - [UIApplication.sharedApplication openURL:url]; + [UIApplication.sharedApplication openURL:url + options:@{} + completionHandler:nil]; } }]; } else { 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 79352d6589..df9e7c9b43 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 @@ -15,7 +15,7 @@ FLUTTER_ASSERT_ARC @interface FlutterAppDelegateTest : XCTestCase @property(strong) FlutterAppDelegate* appDelegate; - +@property(strong) FlutterViewController* viewController; @property(strong) id mockMainBundle; @property(strong) id mockNavigationChannel; @@ -37,6 +37,8 @@ FLUTTER_ASSERT_ARC self.appDelegate = appDelegate; FlutterViewController* viewController = OCMClassMock([FlutterViewController class]); + self.viewController = viewController; + FlutterMethodChannel* navigationChannel = OCMClassMock([FlutterMethodChannel class]); self.mockNavigationChannel = navigationChannel; @@ -172,4 +174,28 @@ FLUTTER_ASSERT_ARC OCMVerifyAll(self.mockNavigationChannel); } +- (void)testUseNonDeprecatedOpenURLAPI { + OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"]) + .andReturn(@YES); + NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"]; + userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=nonexist"]; + OCMStub([self.viewController sendDeepLinkToFramework:[OCMArg any] completionHandler:[OCMArg any]]) + .andDo(^(NSInvocation* invocation) { + void (^handler)(BOOL success); + [invocation getArgument:&handler atIndex:3]; + handler(NO); + }); + id mockApplication = OCMClassMock([UIApplication class]); + OCMStub([mockApplication sharedApplication]).andReturn(mockApplication); + BOOL result = [self.appDelegate + application:[UIApplication sharedApplication] + continueUserActivity:userActivity + restorationHandler:^(NSArray>* __nullable restorableObjects){ + }]; + XCTAssertTrue(result); + OCMVerify([mockApplication openURL:[OCMArg any] + options:[OCMArg any] + completionHandler:[OCMArg any]]); +} + @end