diff --git a/iphone/Maps/Common/AppInfo.h b/iphone/Maps/Common/AppInfo.h index 61be8f3bef..ff7435b156 100644 --- a/iphone/Maps/Common/AppInfo.h +++ b/iphone/Maps/Common/AppInfo.h @@ -21,5 +21,6 @@ typedef NS_ENUM(NSInteger, MWMOpenGLDriver) { @property(nonatomic, readonly) NSDate * buildDate; @property(nonatomic, readonly) NSString * deviceName; @property(nonatomic, readonly) MWMOpenGLDriver openGLDriver; +@property(nonatomic, readonly) BOOL canMakeCalls; @end diff --git a/iphone/Maps/Common/AppInfo.mm b/iphone/Maps/Common/AppInfo.mm index 8c821c7aad..6794d0f267 100644 --- a/iphone/Maps/Common/AppInfo.mm +++ b/iphone/Maps/Common/AppInfo.mm @@ -259,4 +259,16 @@ NSDictionary * const kDeviceNamesWithMetalDriver = @{ return MWMOpenGLDriverMetal; } +- (BOOL)canMakeCalls +{ + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) + return NO; + NSURL * telURL = [NSURL URLWithString:@"tel://"]; + if (![[UIApplication sharedApplication] canOpenURL:telURL]) + return NO; + NSString * networkCode = + [[CTTelephonyNetworkInfo alloc] init].subscriberCellularProvider.mobileNetworkCode; + return networkCode != nil && networkCode.length > 0 && ![networkCode isEqualToString:@"65535"]; +} + @end diff --git a/iphone/Maps/MAPSME.plist b/iphone/Maps/MAPSME.plist index 690fef6870..96dea939db 100644 --- a/iphone/Maps/MAPSME.plist +++ b/iphone/Maps/MAPSME.plist @@ -101,6 +101,7 @@ fbshareextension uber yandextaxi + tel LSRequiresIPhoneOS diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm index 30b4626099..8c4b2c7a17 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/ActionBar/MWMPlacePageActionBar.mm @@ -1,4 +1,5 @@ #import "MWMPlacePageActionBar.h" +#import "AppInfo.h" #import "MWMActionBarButton.h" #import "MWMCommon.h" #import "MWMPlacePageProtocol.h" @@ -50,15 +51,13 @@ extern NSString * const kAlohalyticsTapEventKey; m_visibleButtons.clear(); m_additionalButtons.clear(); auto data = self.data; - NSString * phone = data.phoneNumber; - BOOL const isIphone = [[UIDevice currentDevice].model isEqualToString:@"iPhone"]; - BOOL const isPhoneNotEmpty = phone.length > 0; BOOL const isBooking = data.isBooking; BOOL const isOpentable = data.isOpentable; BOOL const isBookingSearch = data.isBookingSearch; BOOL const isSponsored = isBooking || isOpentable || isBookingSearch; - BOOL const itHasPhoneNumber = isIphone && isPhoneNotEmpty; + BOOL const isPhoneCallAvailable = + [AppInfo sharedInfo].canMakeCalls && data.phoneNumber.length > 0; BOOL const isApi = data.isApi; BOOL const isP2P = [MWMNavigationDashboardManager manager].state != MWMNavigationDashboardStateHidden; @@ -89,7 +88,7 @@ extern NSString * const kAlohalyticsTapEventKey; m_additionalButtons.push_back(EButton::Bookmark); if (isSponsored) m_additionalButtons.push_back(sponsoredButton); - if (itHasPhoneNumber) + if (isPhoneCallAvailable) m_additionalButtons.push_back(EButton::Call); if (isApi) m_additionalButtons.push_back(EButton::Api); @@ -128,7 +127,7 @@ extern NSString * const kAlohalyticsTapEventKey; m_additionalButtons.push_back(EButton::RouteFrom); m_additionalButtons.push_back(EButton::Share); } - else if (isApi && itHasPhoneNumber) + else if (isApi && isPhoneCallAvailable) { m_visibleButtons.push_back(EButton::Api); m_visibleButtons.push_back(EButton::Call); @@ -157,7 +156,7 @@ extern NSString * const kAlohalyticsTapEventKey; m_additionalButtons.push_back(sponsoredButton); m_additionalButtons.push_back(EButton::Share); } - else if (itHasPhoneNumber && isP2P) + else if (isPhoneCallAvailable && isP2P) { m_visibleButtons.push_back(EButton::Bookmark); m_visibleButtons.push_back(EButton::RouteFrom); @@ -171,7 +170,7 @@ extern NSString * const kAlohalyticsTapEventKey; m_additionalButtons.push_back(EButton::RouteFrom); m_additionalButtons.push_back(EButton::Share); } - else if (itHasPhoneNumber) + else if (isPhoneCallAvailable) { m_visibleButtons.push_back(EButton::Call); m_visibleButtons.push_back(EButton::Bookmark);