Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20002](5_1_X) Fix already granted locationcallback #7461

Merged
merged 2 commits into from Nov 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions iphone/Classes/GeolocationModule.m
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
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