Skip to content

Commit

Permalink
[Android] Ensure functions which return a boolean result return an ac…
Browse files Browse the repository at this point in the history
…tual boolean type rather than a binary integer.

Fixes #132.
  • Loading branch information
dpa99c committed Nov 7, 2019
1 parent fa12cb6 commit 4fb46b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions www/firebase.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
var exec = require('cordova/exec');

var ensureBoolean = function (callback){
return function(result){
callback(!!result);
}
};

exports.getVerificationID = function (number, success, error) {
exec(success, error, "FirebasePlugin", "getVerificationID", [number]);
};
Expand Down Expand Up @@ -59,11 +65,11 @@ exports.getBadgeNumber = function (success, error) {
};

exports.grantPermission = function (success, error) {
exec(success, error, "FirebasePlugin", "grantPermission", []);
exec(ensureBoolean(success), error, "FirebasePlugin", "grantPermission", []);
};

exports.hasPermission = function (success, error) {
exec(success, error, "FirebasePlugin", "hasPermission", []);
exec(ensureBoolean(success), error, "FirebasePlugin", "hasPermission", []);
};

// Notifications - Android-only
Expand Down Expand Up @@ -105,7 +111,7 @@ exports.setUserProperty = function (name, value, success, error) {
};

exports.activateFetched = function (success, error) {
exec(success, error, "FirebasePlugin", "activateFetched", []);
exec(ensureBoolean(success), error, "FirebasePlugin", "activateFetched", []);
};

exports.fetch = function (cacheExpirationSeconds, success, error) {
Expand Down

0 comments on commit 4fb46b6

Please sign in to comment.