diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h index e55708e627..86d67218fc 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.h @@ -44,6 +44,7 @@ class Info; - (void)dismissPlacePage; - (void)showPlacePage:(place_page::Info const &)info; +- (void)showPlacePageReview:(place_page::Info const &)info; - (void)addPlace:(BOOL)isBusiness hasPoint:(BOOL)hasPoint point:(m2::PointD const &)point; #pragma mark - MWMNavigationDashboardManager diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 12c0e5af4f..4543e18fc4 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -126,6 +126,14 @@ extern NSString * const kAlohalyticsTapEventKey; }); } +- (void)showPlacePageReview:(place_page::Info const &)info +{ + network_policy::CallPartnersApi([self, info](auto const & /* canUseNetwork */) { + self.trafficButtonHidden = YES; + [self.placePageManager showReview:info]; + }); +} + - (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale { if (![self searchText:text forInputLocale:locale]) diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index a34f5df347..48aab837c9 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -33,6 +33,7 @@ #include "Framework.h" +#include "map/framework_light.hpp" #include "map/gps_tracker.hpp" #include "platform/http_thread_apple.h" @@ -441,6 +442,24 @@ using namespace osm_auth_ios; return; } + lightweight::Framework const framework(lightweight::REQUEST_TYPE_NOTIFICATION); + auto const notificationCandidate = framework.GetNotification(); + if (notificationCandidate) + { + auto const notification = notificationCandidate.get(); + if (notification.m_type == notifications::NotificationCandidate::Type::UgcReview && + notification.m_mapObject) + { + [LocalNotificationManager.sharedManager + showReviewNotificationForPlace:@(notification.m_mapObject->GetReadableName().c_str()) + onTap: ^{ + place_page::Info info; + if (GetFramework().MakePlacePageInfo(*notification.m_mapObject, info)) + [[MapViewController sharedController].controlsManager showPlacePageReview:info]; + }]; + } + } + auto tasks = @[ [[MWMBackgroundStatisticsUpload alloc] init], [[MWMBackgroundEditsUpload alloc] init], [[MWMBackgroundUGCUpload alloc] init], [[MWMBackgroundDownloadMapNotification alloc] init] diff --git a/iphone/Maps/Core/Notifications/LocalNotificationManager.h b/iphone/Maps/Core/Notifications/LocalNotificationManager.h index 43aaacca60..b0baac39d1 100644 --- a/iphone/Maps/Core/Notifications/LocalNotificationManager.h +++ b/iphone/Maps/Core/Notifications/LocalNotificationManager.h @@ -11,6 +11,7 @@ typedef void (^CompletionHandler)(UIBackgroundFetchResult); + (BOOL)isLocalNotification:(UNNotification *)notification; - (BOOL)showUGCNotificationIfNeeded:(MWMVoidBlock)onTap; +- (void)showReviewNotificationForPlace:(NSString *)place onTap:(MWMVoidBlock)onReviewNotification; - (void)showDownloadMapNotificationIfNeeded:(CompletionHandler)completionHandler; - (void)processNotification:(NSDictionary *)userInfo onLaunch:(BOOL)onLaunch; diff --git a/iphone/Maps/Core/Notifications/LocalNotificationManager.mm b/iphone/Maps/Core/Notifications/LocalNotificationManager.mm index aa7cda69f8..71d1cb37df 100644 --- a/iphone/Maps/Core/Notifications/LocalNotificationManager.mm +++ b/iphone/Maps/Core/Notifications/LocalNotificationManager.mm @@ -3,6 +3,7 @@ #import "MWMStorage.h" #import "MapViewController.h" #import "Statistics.h" +#import "SwiftBridge.h" #import "3party/Alohalytics/src/alohalytics_objc.h" #include "Framework.h" @@ -18,6 +19,7 @@ namespace { NSString * const kLocalNotificationNameKey = @"LocalNotificationName"; NSString * const kUGCNotificationValue = @"UGC"; +NSString * const kReviewNotificationValue = @"ReviewNotification"; NSString * const kDownloadNotificationValue = @"Download"; NSString * const kDownloadMapActionKey = @"DownloadMapActionKey"; NSString * const kDownloadMapActionName = @"DownloadMapActionName"; @@ -38,6 +40,7 @@ using namespace storage; @property(copy, nonatomic) CompletionHandler downloadMapCompletionHandler; @property(weak, nonatomic) NSTimer * timer; @property(copy, nonatomic) MWMVoidBlock onTap; +@property(copy, nonatomic) MWMVoidBlock onReviewNotification; @end @@ -123,10 +126,29 @@ using namespace storage; [Statistics logEvent:@"UGC_UnsentNotification_clicked"]; } + else if ([userInfo[kLocalNotificationNameKey] isEqualToString:kReviewNotificationValue]) + { + if (self.onReviewNotification) + self.onReviewNotification(); + } } #pragma mark - Location Notifications +- (void)showReviewNotificationForPlace:(NSString *)place onTap:(MWMVoidBlock)onReviewNotification { + self.onReviewNotification = onReviewNotification; + + UILocalNotification * notification = [[UILocalNotification alloc] init]; + notification.alertTitle = [NSString stringWithCoreFormat:L(@"notification_leave_review_title") + arguments:@[place]]; + notification.alertBody = L(@"notification_leave_review_content"); + notification.alertAction = L(@"leave_a_review"); + notification.soundName = UILocalNotificationDefaultSoundName; + notification.userInfo = @{kLocalNotificationNameKey : kReviewNotificationValue}; + + [UIApplication.sharedApplication presentLocalNotificationNow:notification]; +} + - (BOOL)showUGCNotificationIfNeeded:(MWMVoidBlock)onTap { auto application = UIApplication.sharedApplication; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 99f3c4dd91..85a745ecde 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -95,6 +95,12 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page: @implementation MWMPlacePageManager +- (void)showReview:(place_page::Info const &)info +{ + [self show:info]; + [self showUGCAddReview:MWMRatingSummaryViewValueTypeNoValue fromPreview:YES]; +} + - (void)show:(place_page::Info const &)info { self.isSponsoredOpenLogged = NO; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h index a7ec36df3c..4f9ec0bea2 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageProtocol.h @@ -49,6 +49,7 @@ struct HotelFacility; @protocol MWMPlacePageProtocol - (void)show:(place_page::Info const &)info; +- (void)showReview:(place_page::Info const &)info; - (void)dismiss; - (void)mwm_refreshUI;