Skip to content

Commit

Permalink
Merge pull request #7460 from hansemannn/TIMOB-20002
Browse files Browse the repository at this point in the history
[TIMOB-20002] Fix already granted locationcallback
  • Loading branch information
cheekiatng committed Nov 18, 2015
2 parents adebf56 + 463fde3 commit e2e10ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions iphone/Classes/GeolocationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,10 @@ -(void)requestLocationPermissions:(id)args
}
}

[self executeAndReleaseCallbackWithCode:(errorMessage == nil) ? 0 : 1 andMessage:errorMessage];

if (errorMessage != nil) {
NSLog(@"[ERROR] %@", errorMessage);
[self executeAndReleaseCallbackWithCode:1 andMessage:errorMessage];
RELEASE_TO_NIL(errorMessage);
}
}
Expand Down Expand Up @@ -1079,15 +1080,15 @@ - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatu
if (authorizationCallback != nil && status != kCLAuthorizationStatusNotDetermined) {

int code = 0;
NSString* errorStr = @"";
NSString* errorStr = nil;

switch (status) {
case kCLAuthorizationStatusAuthorizedAlways:
case kCLAuthorizationStatusAuthorizedWhenInUse:
break;
default:
code = 1;
errorStr = @"The user is unable to allow access to location.";
errorStr = @"The user denied access to use location services.";
}

NSMutableDictionary * propertiesDict = [TiUtils dictionaryWithCode:code message:errorStr];
Expand Down
4 changes: 3 additions & 1 deletion iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,10 @@ -(void)requestCameraPermissions:(id)arg
KrollCallback * callback = arg;
TiThreadPerformOnMainThread(^(){
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted){

NSString *errorMessage = granted ? @"The user denied access to use the camera." : nil;
KrollEvent * invocationEvent = [[KrollEvent alloc] initWithCallback:callback
eventObject:[TiUtils dictionaryWithCode:(granted ? 0 : 1) message:nil]
eventObject:[TiUtils dictionaryWithCode:(granted ? 0 : 1) message:errorMessage]
thisObject:self];
[[callback context] enqueue:invocationEvent];
RELEASE_TO_NIL(invocationEvent);
Expand Down

0 comments on commit e2e10ac

Please sign in to comment.