Backurl fixes (#3193)

* Switch from canOpenURL to openURL

Signed-off-by: keithconger <keith.conger@blackboxembedded.com>

* Fix backurl support

Signed-off-by: keithconger <keith.conger@blackboxembedded.com>

* Return nil if backURL is not valid

Signed-off-by: keithconger <keith.conger@blackboxembedded.com>

Signed-off-by: keithconger <keith.conger@blackboxembedded.com>
This commit is contained in:
Black Box Embedded, LLC 2022-08-21 15:20:33 -06:00 committed by GitHub
parent f834411d14
commit 3b2b3070c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 10 deletions

View file

@ -123,7 +123,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
public static final String EXTRA_TASK = "map_task";
public static final String EXTRA_LAUNCH_BY_DEEP_LINK = "launch_by_deep_link";
public static final String EXTRA_BACK_URL = "back_url";
public static final String EXTRA_BACK_URL = "backurl";
private static final String EXTRA_CONSUMED = "mwm.extra.intent.processed";
private static final String[] DOCKED_FRAGMENTS = { SearchFragment.class.getName(),

View file

@ -206,6 +206,15 @@ public class Factory
if (!result.isSuccess())
return false;
final Uri uri = Uri.parse(getUrl());
final String backUrl = uri.getQueryParameter("backurl");
if (!TextUtils.isEmpty(backUrl))
{
Intent intent = target.getIntent();
if (intent != null)
intent.putExtra(MwmActivity.EXTRA_BACK_URL, backUrl);
}
switch (result.getUrlType())
{
case ParsingResult.TYPE_INCORRECT:

View file

@ -719,11 +719,10 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing";
}
- (void)goBack {
NSString *backURL = [DeepLinkHandler.shared getBackUrl];
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:backURL]];
if (canOpenURL){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:backURL] options:@{} completionHandler:nil];
}
NSString *backURL = [DeepLinkHandler.shared getBackUrl];
if (backURL != nil) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: backURL] options:@{} completionHandler:nil];
}
}
@end

View file

@ -33,10 +33,10 @@
url = nil
}
func getBackUrl() -> String {
guard let urlString = url?.absoluteString else { return "" }
guard let url = URLComponents(string: urlString) else { return "" }
return (url.queryItems?.first(where: { $0.name == "backurl" })?.value ?? "")
func getBackUrl() -> String? {
guard let urlString = url?.absoluteString else { return nil }
guard let url = URLComponents(string: urlString) else { return nil }
return (url.queryItems?.first(where: { $0.name == "backurl" })?.value ?? nil)
}
func handleDeepLink() -> Bool {