forked from organicmaps/organicmaps
[iOS] fix guides_page deeplink, fix some post-onboarding deeplinks
This commit is contained in:
parent
3a6601af34
commit
c0db24e054
6 changed files with 19 additions and 16 deletions
|
@ -34,7 +34,7 @@ final class CatalogWebViewController: WebViewController {
|
|||
@objc init(_ deeplinkURL: URL? = nil) {
|
||||
var catalogUrl = MWMBookmarksManager.shared().catalogFrontendUrl()!
|
||||
if let dl = deeplinkURL {
|
||||
if dl.path == "/guides_page" {
|
||||
if dl.host == "guides_page" {
|
||||
if let urlComponents = URLComponents(url: dl, resolvingAgainstBaseURL: false),
|
||||
let path = urlComponents.queryItems?.reduce(into: "", { if $1.name == "url" { $0 = $1.value } }),
|
||||
let url = MWMBookmarksManager.shared().catalogFrontendUrlPlusPath(path) {
|
||||
|
|
|
@ -10,6 +10,11 @@ fileprivate enum DeeplinkType {
|
|||
private(set) var isLaunchedByDeeplink = false
|
||||
private(set) var deeplinkURL: URL?
|
||||
|
||||
var needExtraWelcomeScreen: Bool {
|
||||
guard let host = deeplinkURL?.host else { return false }
|
||||
return host == "catalogue" || host == "guides_page"
|
||||
}
|
||||
|
||||
private var canHandleLink = false
|
||||
private var deeplinkType: DeeplinkType = .common
|
||||
|
||||
|
@ -36,8 +41,11 @@ fileprivate enum DeeplinkType {
|
|||
NSLog("deeplink: applicationDidOpenUrl \(url)")
|
||||
guard let dlType = deeplinkType(url) else { return false }
|
||||
deeplinkType = dlType
|
||||
isLaunchedByDeeplink = true
|
||||
deeplinkURL = url
|
||||
if canHandleLink || !isLaunchedByDeeplink {
|
||||
isLaunchedByDeeplink = true
|
||||
handleInternal()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -84,7 +92,7 @@ fileprivate enum DeeplinkType {
|
|||
}
|
||||
|
||||
private func convertUniversalLink(_ universalLink: URL) -> URL {
|
||||
let convertedLink = String(format: "mapsme://%@?%@", universalLink.path, universalLink.query ?? "")
|
||||
let convertedLink = String(format: "mapsme:/%@?%@", universalLink.path, universalLink.query ?? "")
|
||||
return URL(string: convertedLink)!
|
||||
}
|
||||
|
||||
|
|
|
@ -156,12 +156,6 @@ using namespace osm_auth_ios;
|
|||
return ((EAGLView *)self.mapViewController.view).drapeEngineCreated;
|
||||
}
|
||||
|
||||
- (NSURL *)convertUniversalLink:(NSURL *)universalLink
|
||||
{
|
||||
auto deeplink = [NSString stringWithFormat:@"mapsme://%@?%@", universalLink.path, universalLink.query];
|
||||
return [NSURL URLWithString:deeplink];
|
||||
}
|
||||
|
||||
- (void)searchText:(NSString *)searchString
|
||||
{
|
||||
if (!self.isDrapeEngineCreated)
|
||||
|
@ -345,6 +339,7 @@ using namespace osm_auth_ios;
|
|||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
LOG(LINFO, ("applicationDidEnterBackground - begin"));
|
||||
[DeepLinkHandler.shared reset];
|
||||
if (m_activeDownloadsCounter)
|
||||
{
|
||||
m_backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
||||
|
@ -364,7 +359,6 @@ using namespace osm_auth_ios;
|
|||
{
|
||||
LOG(LINFO, ("applicationWillResignActive - begin"));
|
||||
[self.mapViewController onGetFocus:NO];
|
||||
[DeepLinkHandler.shared reset];
|
||||
auto & f = GetFramework();
|
||||
// On some devices we have to free all belong-to-graphics memory
|
||||
// because of new OpenGL driver powered by Metal.
|
||||
|
|
|
@ -548,7 +548,7 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
- (NSURL * _Nullable)catalogFrontendUrlPlusPath:(NSString *)path
|
||||
{
|
||||
NSString * urlString = @(self.bm.GetCatalog().GetFrontendUrl().c_str());
|
||||
return urlString ? [NSURL URLWithString:[urlString stringByAppendingString:path]] : nil;
|
||||
return urlString ? [NSURL URLWithString:[urlString stringByAppendingPathComponent:path]] : nil;
|
||||
}
|
||||
|
||||
- (NSURL *)sharingUrlForCategoryId:(MWMMarkGroupID)groupId
|
||||
|
|
|
@ -14,13 +14,13 @@ class DeeplinkInfoViewController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
guard let dlUrl = deeplinkURL else { return }
|
||||
switch dlUrl.path {
|
||||
case "/guides_page":
|
||||
guard let dlUrl = deeplinkURL, let host = dlUrl.host else { return }
|
||||
switch host {
|
||||
case "guides_page":
|
||||
alertTitle.text = L("onboarding_guide_direct_download_title")
|
||||
alertText.text = L("onboarding_guide_direct_download_subtitle")
|
||||
nextPageButton.setTitle(L("onboarding_guide_direct_download_button"), for: .normal)
|
||||
case "/catalogue":
|
||||
case "catalogue":
|
||||
alertTitle.text = L("onboarding_bydeeplink_guide_title")
|
||||
alertText.text = L("onboarding_bydeeplink_guide_subtitle")
|
||||
nextPageButton.setTitle(L("current_location_unknown_continue_button"), for: .normal)
|
||||
|
|
|
@ -156,7 +156,7 @@ extension WelcomePageController: WelcomeViewControllerDelegate {
|
|||
if index + 1 < controllers.count {
|
||||
nextPage()
|
||||
} else {
|
||||
if DeepLinkHandler.shared.isLaunchedByDeeplink {
|
||||
if DeepLinkHandler.shared.needExtraWelcomeScreen {
|
||||
let sb = UIStoryboard.instance(.welcome)
|
||||
let vc = sb.instantiateViewController(withIdentifier: "DeeplinkInfoViewController") as! DeeplinkInfoViewController
|
||||
vc.delegate = self
|
||||
|
@ -165,6 +165,7 @@ extension WelcomePageController: WelcomeViewControllerDelegate {
|
|||
nextPage()
|
||||
} else {
|
||||
close()
|
||||
DeepLinkHandler.shared.handleDeeplink()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue