Skip to content

Commit

Permalink
fix(android): resolve undefined for both checkPermissions and request…
Browse files Browse the repository at this point in the history
…Permissions by default (#3855)
  • Loading branch information
carlpoole committed Nov 24, 2020
1 parent f403790 commit 383f62b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ public boolean hasRequiredPermissions() {
@PluginMethod
public void checkPermissions(PluginCall pluginCall) {
JSObject permissionsResult = getPermissionStates();
pluginCall.resolve(permissionsResult);

if (permissionsResult.length() == 0) {
// if no permissions are defined on the plugin, resolve undefined
pluginCall.resolve();
} else {
pluginCall.resolve(permissionsResult);
}
}

/**
Expand Down Expand Up @@ -561,6 +567,7 @@ public void requestPermissions(PluginCall call) {

call.resolve(permissionsResults);
} else {
// no permissions are defined on the plugin, resolve undefined
call.resolve();
}
}
Expand Down

0 comments on commit 383f62b

Please sign in to comment.