From 14f002d10a29c9bea60e694b7ed0f7639a3f83aa Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Sat, 4 Feb 2023 23:01:19 +0100 Subject: [PATCH] [ios] Fixed crash on cold start while opening om:// or https://omaps.app/ links Signed-off-by: Alexander Borsuk --- iphone/Maps/Classes/MapViewController.mm | 8 ++++++++ iphone/Maps/Core/DeepLink/DeepLinkHandler.swift | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index cce48bc7e7..bd258b3885 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -356,6 +356,14 @@ NSString *const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing"; */ } +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + // Cold start deep links should be handled when the map is initialized. + // Otherwise PP container view is nil, or there is no animation/selection of the point. + if (DeepLinkHandler.shared.isLaunchedByDeeplink) + (void)[DeepLinkHandler.shared handleDeepLink]; +} + - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; if (!self.mapView.drapeEngineCreated) diff --git a/iphone/Maps/Core/DeepLink/DeepLinkHandler.swift b/iphone/Maps/Core/DeepLink/DeepLinkHandler.swift index 1928dcba98..8b7b2d1a39 100644 --- a/iphone/Maps/Core/DeepLink/DeepLinkHandler.swift +++ b/iphone/Maps/Core/DeepLink/DeepLinkHandler.swift @@ -16,6 +16,11 @@ } func applicationDidOpenUrl(_ url: URL) -> Bool { + // On the cold start, isLaunchedByDeeplink is set and handleDeepLink() call is delayed + // until the map view will be fully initialized. + guard !isLaunchedByDeeplink else { return true } + + // On the hot start, link can be processed immediately. self.url = url return handleDeepLink(url: url) }