Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f684b7

Browse filesBrowse files
authored
Replace deprecated openURL API call (#164247)
This PR replace the deprecated `openURL:` API with equivalent `openURL:options:completionHandler:` API. *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* #164047 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent b4a69f0 commit 8f684b7
Copy full SHA for 8f684b7

File tree

Expand file treeCollapse file tree

2 files changed

+30
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-2
lines changed

‎engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm

Copy file name to clipboardExpand all lines: engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ - (BOOL)handleOpenURL:(NSURL*)url
164164
completionHandler:^(BOOL success) {
165165
if (!success && throwBack) {
166166
// throw it back to iOS
167-
[UIApplication.sharedApplication openURL:url];
167+
[UIApplication.sharedApplication openURL:url
168+
options:@{}
169+
completionHandler:nil];
168170
}
169171
}];
170172
} else {

‎engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm

Copy file name to clipboardExpand all lines: engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@interface FlutterAppDelegateTest : XCTestCase
1717
@property(strong) FlutterAppDelegate* appDelegate;
18-
18+
@property(strong) FlutterViewController* viewController;
1919
@property(strong) id mockMainBundle;
2020
@property(strong) id mockNavigationChannel;
2121

@@ -37,6 +37,8 @@ - (void)setUp {
3737
self.appDelegate = appDelegate;
3838

3939
FlutterViewController* viewController = OCMClassMock([FlutterViewController class]);
40+
self.viewController = viewController;
41+
4042
FlutterMethodChannel* navigationChannel = OCMClassMock([FlutterMethodChannel class]);
4143
self.mockNavigationChannel = navigationChannel;
4244

@@ -172,4 +174,28 @@ - (void)testUniversalLinkPushRouteInformation {
172174
OCMVerifyAll(self.mockNavigationChannel);
173175
}
174176

177+
- (void)testUseNonDeprecatedOpenURLAPI {
178+
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
179+
.andReturn(@YES);
180+
NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"];
181+
userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=nonexist"];
182+
OCMStub([self.viewController sendDeepLinkToFramework:[OCMArg any] completionHandler:[OCMArg any]])
183+
.andDo(^(NSInvocation* invocation) {
184+
void (^handler)(BOOL success);
185+
[invocation getArgument:&handler atIndex:3];
186+
handler(NO);
187+
});
188+
id mockApplication = OCMClassMock([UIApplication class]);
189+
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication);
190+
BOOL result = [self.appDelegate
191+
application:[UIApplication sharedApplication]
192+
continueUserActivity:userActivity
193+
restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
194+
}];
195+
XCTAssertTrue(result);
196+
OCMVerify([mockApplication openURL:[OCMArg any]
197+
options:[OCMArg any]
198+
completionHandler:[OCMArg any]]);
199+
}
200+
175201
@end

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.