[ios] Add Alohalytics log for location denied event.

This commit is contained in:
Ilya Grechuhin 2015-05-23 13:07:31 +03:00 committed by Alex Zolotarev
parent aefd4e49a3
commit f86a7bcdf5

View file

@ -1,13 +1,17 @@
#import "LocationManager.h"
#include "../../platform/measurement_utils.hpp"
#include "../../platform/settings.hpp"
#include "../../base/math.hpp"
#import "MapViewController.h"
#import "MapsAppDelegate.h"
#import "Statistics.h"
#import "3party/Alohalytics/src/alohalytics_objc.h"
#include "platform/measurement_utils.hpp"
#include "platform/settings.hpp"
#include "base/math.hpp"
static CLAuthorizationStatus const kRequestAuthStatus = kCLAuthorizationStatusAuthorizedAlways;
static NSString * const kAlohalyticsLocationRequestAlwaysFailed = @"$locationAlwaysRequestErrorDenied";
@implementation LocationManager
- (id)init
@ -60,7 +64,7 @@
case kCLAuthorizationStatusAuthorizedWhenInUse:
case kCLAuthorizationStatusAuthorizedAlways:
case kCLAuthorizationStatusNotDetermined:
if ([m_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
if (kRequestAuthStatus == kCLAuthorizationStatusAuthorizedAlways && [m_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[m_locationManager requestAlwaysAuthorization];
[m_locationManager startUpdatingLocation];
if ([CLLocationManager headingAvailable])
@ -196,6 +200,8 @@
NSLog(@"locationManager failed with error: %ld, %@", (long)error.code, error.description);
if (error.code == kCLErrorDenied)
{
if (kRequestAuthStatus == kCLAuthorizationStatusAuthorizedAlways && [m_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[Alohalytics logEvent:kAlohalyticsLocationRequestAlwaysFailed];
for (id observer in m_observers)
[observer onLocationError:location::EDenied];
}