diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 2e5dd7fd06..035433f6d0 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -214,10 +214,7 @@ using namespace osm_auth_ios; switch (parsingType) { case ParsedMapApi::ParsingResult::Incorrect: - if ([m_mwmURL rangeOfString:@"catalog"].location != NSNotFound) - [self.mapViewController openCatalogDeeplink:[[NSURL alloc] initWithString:m_mwmURL] animated:NO]; - else - LOG(LWARNING, ("Incorrect parsing result for url:", url)); + LOG(LWARNING, ("Incorrect parsing result for url:", url)); break; case ParsedMapApi::ParsingResult::Route: { @@ -270,6 +267,9 @@ using namespace osm_auth_ios; break; } + case ParsedMapApi::ParsingResult::Catalogue: + [self.mapViewController openCatalogDeeplink:[[NSURL alloc] initWithString:m_mwmURL] animated:NO]; + break; case ParsedMapApi::ParsingResult::Lead: break; } } @@ -327,18 +327,12 @@ using namespace osm_auth_ios; InitMarketingTrackers(); // Initialize all 3party engines. - BOOL returnValue = [self initStatistics:application didFinishLaunchingWithOptions:launchOptions]; + [self initStatistics:application didFinishLaunchingWithOptions:launchOptions]; // We send Alohalytics installation id to Fabric. // To make sure id is created, ConfigCrashTrackers must be called after Statistics initialization. ConfigCrashTrackers(); - NSURL * urlUsedToLaunchMaps = launchOptions[UIApplicationLaunchOptionsURLKey]; - if (urlUsedToLaunchMaps != nil) - returnValue |= [self checkLaunchURL:urlUsedToLaunchMaps]; - else - returnValue = YES; - [HttpThread setDownloadIndicatorProtocol:self]; InitLocalizedStrings(); @@ -378,7 +372,7 @@ using namespace osm_auth_ios; if (@available(iOS 10, *)) [UNUserNotificationCenter currentNotificationCenter].delegate = self; - return returnValue; + return YES; } - (void)application:(UIApplication *)application @@ -522,7 +516,6 @@ using namespace osm_auth_ios; auto & f = GetFramework(); f.EnterForeground(); [self.mapViewController onGetFocus:YES]; - [self handleURLs]; [[Statistics instance] applicationDidBecomeActive]; f.SetRenderingEnabled(); // On some devices we have to free all belong-to-graphics memory diff --git a/map/mwm_url.cpp b/map/mwm_url.cpp index 82f25f80a4..393cbd94aa 100644 --- a/map/mwm_url.cpp +++ b/map/mwm_url.cpp @@ -95,7 +95,13 @@ char const * kCenterLatLon = "cll"; char const * kLocale = "locale"; char const * kSearchOnMap = "map"; } // namespace search - + +namespace catalogue +{ +char const * kId = "id"; +char const * kName = "name"; +} + namespace { enum class ApiURLType @@ -104,7 +110,8 @@ enum class ApiURLType Map, Route, Search, - Lead + Lead, + Catalogue }; std::array const kAvailableSchemes = {{"mapswithme", "mwm", "mapsme"}}; @@ -123,6 +130,8 @@ ApiURLType URLType(Uri const & uri) return ApiURLType::Search; if (path == "lead") return ApiURLType::Lead; + if (path == "catalogue") + return ApiURLType::Catalogue; return ApiURLType::Incorrect; } @@ -258,6 +267,20 @@ ParsedMapApi::ParsingResult ParsedMapApi::Parse(Uri const & uri) description.Write(); return ParsingResult::Lead; } + case ApiURLType::Catalogue: + { + CatalogItem item; + auto const result = uri.ForEachKeyValue([&item, this](string const & key, string const & value) + { + return CatalogKeyValue(key, value, item); + }); + + if (!result) + return ParsingResult::Incorrect; + + m_catalogItem = item; + return ParsingResult::Catalogue; + } } CHECK_SWITCH(); } @@ -435,6 +458,18 @@ bool ParsedMapApi::LeadKeyValue(string const & key, string const & value, lead:: return true; } +bool ParsedMapApi::CatalogKeyValue(string const & key, string const & value, CatalogItem & item) const +{ + using namespace catalogue; + + if (key == kName) + item.m_name = value; + else if (key == kId) + item.m_id = value; + + return true; +} + void ParsedMapApi::Reset() { m_globalBackUrl.clear(); diff --git a/map/mwm_url.hpp b/map/mwm_url.hpp index a656988306..6718d715a0 100644 --- a/map/mwm_url.hpp +++ b/map/mwm_url.hpp @@ -37,6 +37,11 @@ struct SearchRequest bool m_isSearchOnMap = false; }; +struct CatalogItem +{ + string m_id; + string m_name; +}; namespace lead { @@ -55,7 +60,8 @@ public: Map, Route, Search, - Lead + Lead, + Catalogue }; ParsedMapApi() = default; @@ -76,16 +82,19 @@ public: vector const & GetRoutePoints() const { return m_routePoints; } string const & GetRoutingType() const { return m_routingType; } SearchRequest const & GetSearchRequest() const { return m_request; } + CatalogItem const & GetCatalogItem() const { return m_catalogItem; } private: ParsingResult Parse(Uri const & uri); bool AddKeyValue(string const & key, string const & value, vector & points); bool RouteKeyValue(string const & key, string const & value, vector & pattern); bool SearchKeyValue(string const & key, string const & value, SearchRequest & request) const; bool LeadKeyValue(string const & key, string const & value, lead::CampaignDescription & description) const; + bool CatalogKeyValue(string const & key, string const & value, CatalogItem & item) const; BookmarkManager * m_bmManager = nullptr; vector m_routePoints; SearchRequest m_request; + CatalogItem m_catalogItem; string m_globalBackUrl; string m_appTitle; string m_routingType;