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

Feature/support 0.40 #26

Merged
merged 4 commits into from
Feb 9, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# React Native Touch ID

[![react-native version](https://img.shields.io/badge/react--native-0.40-blue.svg?style=flat-square)](http://facebook.github.io/react-native/releases/0.40)
[![npm version](https://img.shields.io/npm/v/react-native-touch-id.svg?style=flat-square)](https://www.npmjs.com/package/react-native-touch-id)
[![npm downloads](https://img.shields.io/npm/dm/react-native-touch-id.svg?style=flat-square)](https://www.npmjs.com/package/react-native-touch-id)
[![Code Climate](https://img.shields.io/codeclimate/github/naoufal/react-native-touch-id.svg?style=flat-square)](https://codeclimate.com/github/naoufal/react-native-touch-id)
Expand All @@ -22,6 +23,9 @@ React Native Touch ID is a [React Native](http://facebook.github.io/react-native
npm i --save react-native-touch-id
```

## Support
Due to the rapid changes being made in the React Native ecosystem, we are not officially going to support this module on anything but the latest version of React Native. The current supported version is indicated on the React Native badge at the top of this README. If it's out of date, we encourage you to submit a pull request!

## Usage
### Linking the Library
In order to use Touch ID, you must first link the library to your project. There's excellent documentation on how to do this in the [React Native Docs](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).
Expand Down Expand Up @@ -75,31 +79,6 @@ var YourComponent = React.createClass({
});
```

## Fallback
When Touch ID isn't available on a device, you should fallback to using something like [Passcode Auth](https://github.com/naoufal/react-native-passcode-auth) to authenticate users.

```js
import TouchID from 'react-native-touch-id';
import PasscodeAuth from 'react-native-passcode-auth';
const reason = 'to demo this react-native component';

TouchID.authenticate(reason)
.then(success => {
// Success code
})
.catch(fallbackAuth);

function fallbackAuth(reason) {
return PasscodeAuth.authenticate(reason)
.then(success => {
// Success code
})
.catch(error => {
// Failure code
});
}
```

## Methods
### authenticate(reason)
Attempts to authenticate with Touch ID.
Expand Down
4 changes: 2 additions & 2 deletions TouchID.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>

@interface TouchID : NSObject <RCTBridgeModule>

@end
@end
2 changes: 1 addition & 1 deletion TouchID.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "TouchID.h"
#import "RCTUtils.h"
#import <React/RCTUtils.h>
#import <LocalAuthentication/LocalAuthentication.h>

@implementation TouchID
Expand Down
3 changes: 3 additions & 0 deletions examples/TouchIDExample/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
34 changes: 10 additions & 24 deletions examples/TouchIDExample/.flowconfig
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
[ignore]

# We fork some components by platform.
; We fork some components by platform
.*/*[.]android.js

# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Ignore malformed json
.*/node_modules/y18n/test/.*\.json

# Ignore the website subdir
<PROJECT_ROOT>/website/.*

# Ignore BUCK generated dirs
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*

[include]

Expand All @@ -34,25 +24,21 @@ flow/
[options]
module.system=haste

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
^0.32.0
^0.36.0
1 change: 1 addition & 0 deletions examples/TouchIDExample/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
18 changes: 15 additions & 3 deletions examples/TouchIDExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ DerivedData
*.xcuserstate
project.xcworkspace

# Android/IJ
# Android/IntelliJ
#
*.iml
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
Expand All @@ -38,4 +39,15 @@ npm-debug.log
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
4 changes: 2 additions & 2 deletions examples/TouchIDExample/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
from configurations.compile
into 'libs'
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.touchidexample">
package="com.touchidexample"
android:versionCode="1"
android:versionName="1.0">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />

<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;
Expand All @@ -30,6 +31,12 @@ protected List<ReactPackage> getPackages() {

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
8 changes: 8 additions & 0 deletions examples/TouchIDExample/android/keystores/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
keystore(
name = 'debug',
store = 'debug.keystore',
properties = 'debug.keystore.properties',
visibility = [
'PUBLIC',
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
key.store=debug.keystore
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android
4 changes: 1 addition & 3 deletions examples/TouchIDExample/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from 'react-native';

import TouchID from "react-native-touch-id";
import PasscodeAuth from "react-native-passcode-auth";

class TouchIDExample extends Component {
render() {
Expand Down Expand Up @@ -41,11 +40,10 @@ class TouchIDExample extends Component {
}

_clickHandler() {
console.log(TouchID);
TouchID.isSupported()
.then(authenticate)
.catch(error => {
passcodeAuth();
AlertIOS.alert('TouchID not supported');
});
}
}
Expand Down
Loading