diff options
-rw-r--r-- | iphone/Maps/Classes/MapsAppDelegate.mm | 71 | ||||
-rw-r--r-- | iphone/Maps/Core/Notifications/LocalNotificationManager.h | 2 | ||||
-rw-r--r-- | iphone/Maps/Core/Notifications/LocalNotificationManager.mm | 3 |
3 files changed, 28 insertions, 48 deletions
diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index a9775f6778..67379faee1 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -1,5 +1,7 @@ #import "MapsAppDelegate.h" - +#import <CoreSpotlight/CoreSpotlight.h> +#import <FBSDKCoreKit/FBSDKCoreKit.h> +#import "3party/Alohalytics/src/alohalytics_objc.h" #import "EAGLView.h" #import "LocalNotificationManager.h" #import "MWMAuthorizationCommon.h" @@ -17,20 +19,6 @@ #import "Statistics.h" #import "SwiftBridge.h" -#import "3party/Alohalytics/src/alohalytics_objc.h" - -#import <CoreSpotlight/CoreSpotlight.h> -#import <FBSDKCoreKit/FBSDKCoreKit.h> -#import <UserNotifications/UserNotifications.h> - -#ifdef OMIM_PRODUCTION - -#import <AppsFlyerTracker/AppsFlyerTracker.h> -#import <Crashlytics/Crashlytics.h> -#import <Fabric/Fabric.h> - -#endif - #include "Framework.h" #include "map/gps_tracker.hpp" @@ -38,9 +26,17 @@ #include "platform/http_thread_apple.h" #include "platform/local_country_file_utils.hpp" -#include "private.h" // If you have a "missing header error" here, then please run configure.sh script in the root repo // folder. +#import "private.h" + +#ifdef OMIM_PRODUCTION + +#import <AppsFlyerTracker/AppsFlyerTracker.h> +#import <Crashlytics/Crashlytics.h> +#import <Fabric/Fabric.h> + +#endif extern NSString * const MapsStatusChangedNotification = @"MapsStatusChangedNotification"; // Alert keys. @@ -126,7 +122,7 @@ void TrackMarketingAppLaunch() using namespace osm_auth_ios; -@interface MapsAppDelegate ()<MWMFrameworkStorageObserver, UNUserNotificationCenterDelegate> +@interface MapsAppDelegate ()<MWMFrameworkStorageObserver> @property(nonatomic) NSInteger standbyCounter; @property(nonatomic) MWMBackgroundFetchScheduler * backgroundFetchScheduler; @@ -345,12 +341,18 @@ using namespace osm_auth_ios; InitMarketingTrackers(); // Initialize all 3party engines. - [self initStatistics:application didFinishLaunchingWithOptions:launchOptions]; + BOOL returnValue = [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(); @@ -360,10 +362,9 @@ using namespace osm_auth_ios; LocalNotificationManager * notificationManager = [LocalNotificationManager sharedManager]; if (launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]) - { - NSNotification * notification = launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]; - [notificationManager processNotification:notification.userInfo onLaunch:YES]; - } + [notificationManager + processNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey] + onLaunch:YES]; if ([Alohalytics isFirstSession]) { @@ -387,10 +388,7 @@ using namespace osm_auth_ios; [GIDSignIn sharedInstance].clientID = [[NSBundle mainBundle] loadWithPlist:@"GoogleService-Info"][@"CLIENT_ID"]; - if (@available(iOS 10, *)) - [UNUserNotificationCenter currentNotificationCenter].delegate = self; - - return YES; + return returnValue; } - (void)application:(UIApplication *)application @@ -705,29 +703,10 @@ using namespace osm_auth_ios; }; } -- (void)userNotificationCenter:(UNUserNotificationCenter *)center - willPresentNotification:(UNNotification *)notification - withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler -{ - completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound); -} - -- (void)userNotificationCenter:(UNUserNotificationCenter *)center -didReceiveNotificationResponse:(UNNotificationResponse *)response - withCompletionHandler:(void(^)(void))completionHandler -{ - if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) - { - auto userInfo = response.notification.request.content.userInfo; - [[LocalNotificationManager sharedManager] processNotification:userInfo onLaunch:NO]; - } - completionHandler(); -} - - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - [[LocalNotificationManager sharedManager] processNotification:notification.userInfo onLaunch:NO]; + [[LocalNotificationManager sharedManager] processNotification:notification onLaunch:NO]; } - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options diff --git a/iphone/Maps/Core/Notifications/LocalNotificationManager.h b/iphone/Maps/Core/Notifications/LocalNotificationManager.h index fd6536edbe..09ad657f81 100644 --- a/iphone/Maps/Core/Notifications/LocalNotificationManager.h +++ b/iphone/Maps/Core/Notifications/LocalNotificationManager.h @@ -9,6 +9,6 @@ typedef void (^CompletionHandler)(UIBackgroundFetchResult); - (BOOL)showUGCNotificationIfNeeded:(MWMVoidBlock)onTap; - (void)showDownloadMapNotificationIfNeeded:(CompletionHandler)completionHandler; -- (void)processNotification:(NSDictionary *)userInfo onLaunch:(BOOL)onLaunch; +- (void)processNotification:(UILocalNotification *)notification onLaunch:(BOOL)onLaunch; @end diff --git a/iphone/Maps/Core/Notifications/LocalNotificationManager.mm b/iphone/Maps/Core/Notifications/LocalNotificationManager.mm index d74f8cda37..875a49f3e5 100644 --- a/iphone/Maps/Core/Notifications/LocalNotificationManager.mm +++ b/iphone/Maps/Core/Notifications/LocalNotificationManager.mm @@ -87,8 +87,9 @@ using namespace storage; } - (void)dealloc { _locationManager.delegate = nil; } -- (void)processNotification:(NSDictionary *)userInfo onLaunch:(BOOL)onLaunch +- (void)processNotification:(UILocalNotification *)notification onLaunch:(BOOL)onLaunch { + NSDictionary * userInfo = [notification userInfo]; if ([userInfo[kDownloadMapActionKey] isEqualToString:kDownloadMapActionName]) { [Statistics logEvent:@"'Download Map' Notification Clicked"]; |