Skip to content

Commit 07c97da

Browse files
committed
[0.1.1] iOS stuff. Version fixes. Readme example fix.
1 parent 2e07670 commit 07c97da

File tree

6 files changed

+130
-82
lines changed

6 files changed

+130
-82
lines changed

example/index.ios.js

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,67 @@
1-
/**
2-
* Sample React Native App
3-
* https://github.com/facebook/react-native
4-
* @flow
5-
*/
1+
//@flow
62

73
import React, { Component } from 'react';
8-
import {
9-
AppRegistry,
10-
StyleSheet,
11-
Text,
12-
View
13-
} from 'react-native';
14-
import FingerprintAndroid from 'react-native-fingerprint-android';
4+
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
5+
import { default as Fingerprint } from 'react-native-fingerprint-android';
156

167
class example extends Component {
17-
render() {
18-
return (
19-
<View style={styles.container}>
20-
<Text style={styles.welcome}>
21-
Welcome to FingerprintAndroid!
22-
</Text>
23-
<Text style={styles.instructions}>
24-
However, as the name might suggest, this library is android-only.
25-
</Text>
26-
<Text style={styles.instructions}>
27-
This version of the app only exists to check if iOS doesn't crash.
28-
</Text>
29-
<Text style={styles.instructions}>
30-
The following should say 'false': {FingerprintAndroid.isHardwareSupported()}
31-
</Text>
32-
</View>
33-
);
34-
}
8+
state = {
9+
enrolled: undefined,
10+
supported: undefined,
11+
permission: undefined
12+
}
13+
14+
async componentDidMount() {
15+
this.setState({
16+
enrolled: await Fingerprint.hasEnrolledFingerprints(),
17+
supported: await Fingerprint.isHardwareDetected(),
18+
permission: await Fingerprint.hasPermission(),
19+
})
20+
}
21+
22+
render() {
23+
return (
24+
<View style={styles.container}>
25+
<Text style={styles.welcome}>
26+
Welcome to FingerprintAndroid!
27+
</Text>
28+
<Text style={styles.instructions}>
29+
However, as the name might suggest, this library is android-only.
30+
</Text>
31+
<Text style={styles.instructions}>
32+
This version of the app only exists to check if iOS doesn't crash.
33+
</Text>
34+
<Text style={styles.instructions}>
35+
Hardware detected (should be false): {this.state.supported}
36+
</Text>
37+
<Text style={styles.instructions}>
38+
Has permission (should be false): {this.state.permission}
39+
</Text>
40+
<Text style={styles.instructions}>
41+
Is enrolled (should be false): {this.state.enrolled}
42+
</Text>
43+
</View>
44+
);
45+
}
3546
}
3647

3748
const styles = StyleSheet.create({
38-
container: {
39-
flex: 1,
40-
justifyContent: 'center',
41-
alignItems: 'center',
42-
backgroundColor: '#F5FCFF',
43-
},
44-
welcome: {
45-
fontSize: 20,
46-
textAlign: 'center',
47-
margin: 10,
48-
},
49-
instructions: {
50-
textAlign: 'center',
51-
color: '#333333',
52-
marginBottom: 5,
53-
},
49+
container: {
50+
flex: 1,
51+
justifyContent: 'center',
52+
alignItems: 'center',
53+
backgroundColor: '#F5FCFF',
54+
},
55+
welcome: {
56+
fontSize: 20,
57+
textAlign: 'center',
58+
margin: 10,
59+
},
60+
instructions: {
61+
textAlign: 'center',
62+
color: '#333333',
63+
marginBottom: 5,
64+
},
5465
});
5566

5667
AppRegistry.registerComponent('example', () => example);

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
};
66
objectVersion = 46;
77
objects = {
8+
89
/* Begin PBXBuildFile section */
910
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1011
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -89,6 +90,13 @@
8990
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
9091
remoteInfo = React;
9192
};
93+
4942AF831D90842800AE664C /* PBXContainerItemProxy */ = {
94+
isa = PBXContainerItemProxy;
95+
containerPortal = BA8E3B695AAB49BEB409E181 /* RNSVG.xcodeproj */;
96+
proxyType = 2;
97+
remoteGlobalIDString = 0CF68AC11AF0540F00FF9E5C;
98+
remoteInfo = RNSVG;
99+
};
92100
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
93101
isa = PBXContainerItemProxy;
94102
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
@@ -106,29 +114,29 @@
106114
/* End PBXContainerItemProxy section */
107115

108116
/* Begin PBXFileReference section */
109-
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = main.jsbundle; sourceTree = "<group>"; };
110-
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
111-
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = "<group>"; };
112-
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
113-
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
114-
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
117+
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
118+
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = "<group>"; };
119+
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = "<group>"; };
120+
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = "<group>"; };
121+
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = "<group>"; };
122+
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = "<group>"; };
115123
00E356EE1AD99517003FC87E /* exampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = exampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
116124
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
117125
00E356F21AD99517003FC87E /* exampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = exampleTests.m; sourceTree = "<group>"; };
118-
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
119-
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = "<group>"; };
126+
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
127+
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = "<group>"; };
120128
13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
121129
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = example/AppDelegate.h; sourceTree = "<group>"; };
122130
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = example/AppDelegate.m; sourceTree = "<group>"; };
123131
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
124132
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; };
125133
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; };
126134
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = example/main.m; sourceTree = "<group>"; };
127-
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../node_modules/react-native/React/React.xcodeproj; sourceTree = "<group>"; };
128-
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = "<group>"; };
129-
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
130-
BA8E3B695AAB49BEB409E181 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; name = "RNSVG.xcodeproj"; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
131-
8870D0A1380147D6B6E2567E /* libRNSVG.a */ = {isa = PBXFileReference; name = "libRNSVG.a"; path = "libRNSVG.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
135+
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
136+
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
137+
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
138+
8870D0A1380147D6B6E2567E /* libRNSVG.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNSVG.a; sourceTree = "<group>"; };
139+
BA8E3B695AAB49BEB409E181 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSVG.xcodeproj; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = "<group>"; };
132140
/* End PBXFileReference section */
133141

134142
/* Begin PBXFrameworksBuildPhase section */
@@ -256,6 +264,14 @@
256264
name = Products;
257265
sourceTree = "<group>";
258266
};
267+
4942AF761D90842800AE664C /* Products */ = {
268+
isa = PBXGroup;
269+
children = (
270+
4942AF841D90842800AE664C /* libRNSVG.a */,
271+
);
272+
name = Products;
273+
sourceTree = "<group>";
274+
};
259275
78C398B11ACF4ADC00677621 /* Products */ = {
260276
isa = PBXGroup;
261277
children = (
@@ -417,6 +433,10 @@
417433
ProductGroup = 146834001AC3E56700842450 /* Products */;
418434
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
419435
},
436+
{
437+
ProductGroup = 4942AF761D90842800AE664C /* Products */;
438+
ProjectRef = BA8E3B695AAB49BEB409E181 /* RNSVG.xcodeproj */;
439+
},
420440
);
421441
projectRoot = "";
422442
targets = (
@@ -483,6 +503,13 @@
483503
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
484504
sourceTree = BUILT_PRODUCTS_DIR;
485505
};
506+
4942AF841D90842800AE664C /* libRNSVG.a */ = {
507+
isa = PBXReferenceProxy;
508+
fileType = archive.ar;
509+
path = libRNSVG.a;
510+
remoteRef = 4942AF831D90842800AE664C /* PBXContainerItemProxy */;
511+
sourceTree = BUILT_PRODUCTS_DIR;
512+
};
486513
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
487514
isa = PBXReferenceProxy;
488515
fileType = archive.ar;
@@ -532,7 +559,6 @@
532559
runOnlyForDeploymentPostprocessing = 0;
533560
shellPath = /bin/sh;
534561
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
535-
showEnvVarsInLog = 1;
536562
};
537563
/* End PBXShellScriptBuildPhase section */
538564

@@ -588,12 +614,12 @@
588614
INFOPLIST_FILE = exampleTests/Info.plist;
589615
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
590616
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
591-
PRODUCT_NAME = "$(TARGET_NAME)";
592-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
593617
LIBRARY_SEARCH_PATHS = (
594618
"$(inherited)",
595619
"\"$(SRCROOT)/$(TARGET_NAME)\"",
596620
);
621+
PRODUCT_NAME = "$(TARGET_NAME)";
622+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
597623
};
598624
name = Debug;
599625
};
@@ -605,12 +631,12 @@
605631
INFOPLIST_FILE = exampleTests/Info.plist;
606632
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
607633
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
608-
PRODUCT_NAME = "$(TARGET_NAME)";
609-
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
610634
LIBRARY_SEARCH_PATHS = (
611635
"$(inherited)",
612636
"\"$(SRCROOT)/$(TARGET_NAME)\"",
613637
);
638+
PRODUCT_NAME = "$(TARGET_NAME)";
639+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
614640
};
615641
name = Release;
616642
};
@@ -625,7 +651,7 @@
625651
"$(SRCROOT)/../node_modules/react-native/React/**",
626652
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
627653
);
628-
INFOPLIST_FILE = "example/Info.plist";
654+
INFOPLIST_FILE = example/Info.plist;
629655
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
630656
OTHER_LDFLAGS = (
631657
"$(inherited)",
@@ -646,7 +672,7 @@
646672
"$(SRCROOT)/../node_modules/react-native/React/**",
647673
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
648674
);
649-
INFOPLIST_FILE = "example/Info.plist";
675+
INFOPLIST_FILE = example/Info.plist;
650676
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
651677
OTHER_LDFLAGS = (
652678
"$(inherited)",

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"dependencies": {
99
"color": "^0.11.3",
1010
"react": "15.3.1",
11-
"react-native": "0.32.1",
11+
"react-native": "^0.33.0",
1212
"react-native-animatable": "^0.6.1",
1313
"react-native-fingerprint-android": "file:..",
14-
"react-native-svg": "^4.3.0"
14+
"react-native-svg": "^4.3.1"
1515
}
1616
}

index.ios.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Fake class.
3+
* isHardwareDetected() should be enough on it's own, which is the reason not everything has been stubbed.
4+
* (and if you are actually smart enough to call authenticate() it will just crash...)
5+
*/
6+
17
export default class FingerprintAndroid {
28
static async cancelAuthentication(): Promise<null> {
39
return null;

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"name": "react-native-fingerprint-android",
3-
"version": "0.1.0",
4-
"description": "Simple fingerprint authentication for Android",
5-
"scripts": {
6-
"test": "echo \"Error: no test specified\" && exit 1"
7-
},
8-
"peerDependencies": {
9-
"react-native": "*"
10-
},
11-
"author": "Jari Zwarts",
12-
"license": "MIT"
2+
"name": "react-native-fingerprint-android",
3+
"version": "0.1.1",
4+
"description": "Simple fingerprint authentication for Android",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"peerDependencies": {
9+
"react-native": "*"
10+
},
11+
"nativePackage": true,
12+
"author": "Jari Zwarts",
13+
"license": "MIT"
1314
}

readme.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ import { ToastAndroid as Toast } from 'react-native';
2626
return;
2727
}
2828

29-
await Fingerprint.authenticate(warning => {
30-
Toast.show(`Try again: ${warning.message}`, Toast.SHORT);
31-
});
29+
try {
30+
await Fingerprint.authenticate(warning => {
31+
Toast.show(`Try again: ${warning.message}`, Toast.SHORT);
32+
});
33+
} catch(error) {
34+
Toast.show(`Try again: ${error.message}`, Toast.SHORT);
35+
}
3236

3337
Toast.show("Auth successful!", Toast.SHORT);
3438
})();

0 commit comments

Comments
 (0)