Skip to content

Commit

Permalink
Generator code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
audaciouscode committed Jun 22, 2017
1 parent c0f5857 commit df701da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
5 changes: 0 additions & 5 deletions PassiveDataKit/PDKGooglePlacesGenerator.m
Expand Up @@ -257,9 +257,6 @@ - (void) transmitPlacesForFreetextQuery:(NSString *) query {

NSDictionary * response = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&error];

NSLog(@"response: %@", response);
NSLog(@"count: %d", (int) [response[@"results"] count]);

NSMutableDictionary * log = [NSMutableDictionary dictionary];
[log setValue:[NSDate date] forKey:@"recorded"];
[log setValue:response[@"results"] forKey:@"response"];
Expand All @@ -280,8 +277,6 @@ - (void) transmitPlacesForFreetextQuery:(NSString *) query {
}
}

NSLog(@"DATA: %@", data);

for (id<PDKDataListener> listener in weakSelf.listeners) {
[listener receivedData:data forGenerator:PDKGooglePlaces];
}
Expand Down
12 changes: 9 additions & 3 deletions PassiveDataKit/PDKLocationGenerator.m
Expand Up @@ -21,6 +21,8 @@ @interface PDKLocationGenerator ()
@property NSDictionary * lastOptions;
@property NSString * mode;

@property (nonatomic, copy) void (^accessDeniedBlock)(void);

@end

NSString * const PDKLocationAccuracyMode = @"PDKLocationAccuracyMode"; //!OCLINT
Expand Down Expand Up @@ -117,16 +119,20 @@ - (void) addListener:(id<PDKDataListener>)listener options:(NSDictionary *) opti
}

self.lastOptions = options;


self.accessDeniedBlock = [options valueForKey:PDKLocationAccessDenied];

if (self.listeners.count == 0) {
// Turn on sensors with options...

NSNumber * alwaysOn = [options valueForKey:PDKLocationAlwaysOn];

CLAuthorizationStatus status = [CLLocationManager authorizationStatus];

if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied) { //!OCLINT
// Do nothing - user shut off location services...
if (self.accessDeniedBlock != nil) {
self.accessDeniedBlock();
}
} else if (status == kCLAuthorizationStatusNotDetermined) {
if (alwaysOn != nil && alwaysOn.boolValue) {
[self.locationManager requestAlwaysAuthorization];
Expand Down
2 changes: 2 additions & 0 deletions PassiveDataKit/PassiveDataKit.h
Expand Up @@ -20,6 +20,8 @@ extern NSString *const PDKLocationAlwaysOn;
extern NSString *const PDKLocationRequestedAccuracy;
extern NSString *const PDKLocationRequestedDistance;
extern NSString *const PDKLocationInstance;
extern NSString *const PDKLocationAccessDenied;

extern NSString *const PDKMixpanelToken;

extern NSString *const PDKGooglePlacesSpecificLocation;
Expand Down
2 changes: 2 additions & 0 deletions PassiveDataKit/PassiveDataKit.m
Expand Up @@ -28,6 +28,8 @@ @interface PassiveDataKit ()
NSString * const PDKLocationRequestedAccuracy = @"PDKLocationRequestedAccuracy"; //!OCLINT
NSString * const PDKLocationRequestedDistance = @"PDKLocationRequestedDistance"; //!OCLINT
NSString * const PDKLocationInstance = @"PDKLocationInstance"; //!OCLINT
NSString * const PDKLocationAccessDenied = @"PDKLocationAccessDenied"; //!OCLINT

NSString * const PDKUserIdentifier = @"PDKUserIdentifier"; //!OCLINT
NSString * const PDKGenerator = @"PDKGenerator"; //!OCLINT
NSString * const PDKGeneratorIdentifier = @"PDKGeneratorIdentifier"; //!OCLINT
Expand Down

0 comments on commit df701da

Please sign in to comment.