Skip to content

Commit

Permalink
add backwards compatibility with callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
naoufal committed Jun 5, 2015
1 parent f0c89b0 commit 7dfdfa8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion TouchID.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ var ERRORS = require('./data/errors');
*/

var TouchID = {
authenticate() {
authenticate(callback) {
// Return callback function if a callback is passed
if (typeof callback === 'function') {
return NativeTouchID.authenticate(function(error, success) {
if (error) {
return callback(createError(error.message));
}

callback(null, success);
});
}

// Return Promise if no callback is passed
return new Promise(function(resolve, reject) {
NativeTouchID.authenticate(function(error, success) {
// Return error if rejected
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-touch-id",
"version": "2.0.0",
"version": "1.1.0",
"description": "React Native authentication with the native Touch ID popup.",
"scripts": {
"start": "node_modules/react-native/packager/packager.sh"
Expand Down

0 comments on commit 7dfdfa8

Please sign in to comment.