[iOS] add ugc review notifications

This commit is contained in:
Aleksey Belouosv 2018-11-28 16:06:22 +03:00 committed by Olesia Bolovintseva
parent 0b8b230e0c
commit 20149f7552
7 changed files with 58 additions and 0 deletions

View file

@ -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

View file

@ -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])

View file

@ -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]

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -49,6 +49,7 @@ struct HotelFacility;
@protocol MWMPlacePageProtocol<MWMActionBarProtocol, MWMPlacePageButtonsProtocol, MWMFeatureHolder, MWMBookingInfoHolder>
- (void)show:(place_page::Info const &)info;
- (void)showReview:(place_page::Info const &)info;
- (void)dismiss;
- (void)mwm_refreshUI;