From beb9e881b46ecdd1d3bc059823e0f8e1daf9058a Mon Sep 17 00:00:00 2001 From: Arsentiy Milchakov Date: Thu, 25 Apr 2019 19:05:36 +0300 Subject: [PATCH] [ios][booking] use single deep link when booking.com app is installed --- .../Maps/UI/PlacePage/MWMPlacePageManager.mm | 34 ++++++++++++------- partners_api/booking_api.cpp | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 0628d24c1b..bfe762de50 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -488,6 +488,20 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: [self.ownerViewController openFullPlaceDescriptionWithHtml:htmlString]; } +- (void)openPartnerWithStatisticLog:(NSString *)eventName proposedUrl:(NSURL *)proposedUrl +{ + auto data = self.data; + if (!data) + return; + + logSponsoredEvent(data, eventName); + + NSURL * url = data.isPartnerAppInstalled ? data.deepLink : proposedUrl; + NSAssert(url, @"Sponsored url can't be nil!"); + + [UIApplication.sharedApplication openURL:url options:@{} completionHandler:nil]; +} + - (void)book { auto data = self.data; @@ -507,12 +521,8 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: NSAssert(false, @"Invalid book case!"); return; } - logSponsoredEvent(data, eventName); - NSURL * url = data.isPartnerAppInstalled ? data.deepLink : data.sponsoredURL; - NSAssert(url, @"Sponsored url can't be nil!"); - - [UIApplication.sharedApplication openURL:url options:@{} completionHandler:nil]; + [self openPartnerWithStatisticLog:eventName proposedUrl:data.sponsoredURL]; } - (void)openDescriptionUrl @@ -520,10 +530,9 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: auto data = self.data; if (!data) return; - - logSponsoredEvent(data, kStatPlacePageHotelDetails); - [UIApplication.sharedApplication openURL:data.sponsoredDescriptionURL - options:@{} completionHandler:nil]; + + [self openPartnerWithStatisticLog:kStatPlacePageHotelDetails + proposedUrl:data.sponsoredDescriptionURL]; } - (void)openMoreUrl @@ -531,7 +540,7 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: auto data = self.data; if (!data) return; - + logSponsoredEvent(data, kStatPlacePageHotelMore); [UIApplication.sharedApplication openURL:data.sponsoredMoreURL options:@{} completionHandler:nil]; @@ -543,9 +552,8 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: if (!data) return; - logSponsoredEvent(data, kStatPlacePageHotelReviews); - [UIApplication.sharedApplication openURL:data.sponsoredReviewURL - options:@{} completionHandler:nil]; + [self openPartnerWithStatisticLog:kStatPlacePageHotelReviews + proposedUrl:data.sponsoredReviewURL]; } - (void)searchBookingHotels diff --git a/partners_api/booking_api.cpp b/partners_api/booking_api.cpp index 2280c507d0..4b76650779 100644 --- a/partners_api/booking_api.cpp +++ b/partners_api/booking_api.cpp @@ -509,7 +509,7 @@ string Api::GetSearchUrl(string const & city, string const & name) const return {}; url::Params p = {{"&ss=", urlEncodedParams}}; - return url::Make(AppendAidAndLabel(kSearchBaseUrl, "ppActionButton"), p); + return url::Make(AppendAidAndLabel(kSearchBaseUrl, "ppActionButtonOSM"), p); } string Api::ApplyAvailabilityParams(string const & url, AvailabilityParams const & params) const