Skip to content

Commit

Permalink
fix(android): allow location permission request to fall through
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Feb 27, 2019
1 parent 44ca73a commit 54fb06c
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,21 @@ public boolean hasLocationPermissions()
public void requestLocationPermissions(@Kroll.argument(optional = true) Object type,
@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasLocationPermissions()) {
return;
}

KrollFunction permissionCB;
if (type instanceof KrollFunction && permissionCallback == null) {
permissionCB = (KrollFunction) type;
} else {
permissionCB = permissionCallback;
}

// already have permissions, fall through
if (hasLocationPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCB.callAsync(getKrollObject(), response);
return;
}

TiBaseActivity.registerPermissionRequestCallback(TiC.PERMISSION_CODE_LOCATION, permissionCB, getKrollObject());
Activity currentActivity = TiApplication.getInstance().getCurrentActivity();
currentActivity.requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION },
Expand Down

0 comments on commit 54fb06c

Please sign in to comment.