Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set deep linking flag to true by default #52350

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1399,14 +1399,20 @@ public boolean shouldAttachEngineToActivity() {
* <p>The default implementation looks {@code <meta-data>} called {@link
* FlutterActivityLaunchConfigs#HANDLE_DEEPLINKING_META_DATA_KEY} within the Android manifest
* definition for this {@code FlutterActivity}.
*
* <p>Defaults to {@code true}.
*/
@Override
public boolean shouldHandleDeeplinking() {
try {
Bundle metaData = getMetaData();
boolean shouldHandleDeeplinking =
metaData != null ? metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY) : false;
return shouldHandleDeeplinking;
// Check if metadata is not null and contains the HANDLE_DEEPLINKING_META_DATA_KEY.
if (metaData != null && metaData.containsKey(HANDLE_DEEPLINKING_META_DATA_KEY)) {
return metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY);
} else {
// Return true if the deep linking flag is not found in metadata.
return true;
}
} catch (PackageManager.NameNotFoundException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,20 @@ protected boolean shouldAttachEngineToActivity() {
* <p>The default implementation looks {@code <meta-data>} called {@link
* FlutterActivityLaunchConfigs#HANDLE_DEEPLINKING_META_DATA_KEY} within the Android manifest
* definition for this {@code FlutterFragmentActivity}.
*
* <p>Defaults to {@code true}.
*/
@VisibleForTesting
protected boolean shouldHandleDeeplinking() {
try {
Bundle metaData = getMetaData();
boolean shouldHandleDeeplinking =
metaData != null ? metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY) : false;
return shouldHandleDeeplinking;
// Check if metadata is not null and contains the HANDLE_DEEPLINKING_META_DATA_KEY.
if (metaData != null && metaData.containsKey(HANDLE_DEEPLINKING_META_DATA_KEY)) {
return metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY);
} else {
// Return true if the deep linking flag is not found in metadata.
return true;
}
} catch (PackageManager.NameNotFoundException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ public void itReturnsValueFromMetaDataWhenCallsShouldHandleDeepLinkingCase3()
Bundle bundle = new Bundle();
FlutterActivity spyFlutterActivity = spy(flutterActivity);
when(spyFlutterActivity.getMetaData()).thenReturn(bundle);
// Empty bundle should return false.
assertFalse(spyFlutterActivity.shouldHandleDeeplinking());
// Empty bundle should return true.
assertTrue(spyFlutterActivity.shouldHandleDeeplinking());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public void itReturnsValueFromMetaDataWhenCallsShouldHandleDeepLinkingCase3()
Bundle bundle = new Bundle();
FlutterFragmentActivity spyFlutterActivity = spy(activity);
when(spyFlutterActivity.getMetaData()).thenReturn(bundle);
// Empty bundle should return false.
assertFalse(spyFlutterActivity.shouldHandleDeeplinking());
// Empty bundle should return true.
assertTrue(spyFlutterActivity.shouldHandleDeeplinking());
hangyujin marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter*)center
- (BOOL)openURL:(NSURL*)url {
NSNumber* isDeepLinkingEnabled =
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"];
if (!isDeepLinkingEnabled.boolValue) {
// Not set or NO.
if ([isDeepLinkingEnabled isEqual:@NO]) {
// The flag is set to NO.
return NO;
} else {
// The flag is not set or set to YES.
FlutterViewController* flutterViewController = [self rootFlutterViewController];
if (flutterViewController) {
[flutterViewController.engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ - (void)testLaunchUrlWithDeepLinkingNotSet {
[self.appDelegate application:[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
options:@{}];
XCTAssertFalse(result);
OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
XCTAssertTrue(result);
hangyujin marked this conversation as resolved.
Show resolved Hide resolved
OCMVerify([self.mockNavigationChannel
invokeMethod:@"pushRouteInformation"
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
}

- (void)testLaunchUrlWithDeepLinkingDisabled {
Expand Down