Skip to content

Commit d1a56b5

Browse files
committed
Update example
1 parent 77ed1f3 commit d1a56b5

File tree

9 files changed

+69
-53
lines changed

9 files changed

+69
-53
lines changed

example/App.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet, Text, View, TouchableHighlight, ScrollView, TextInput, Alert } from 'react-native';
2+
import { StyleSheet, Text, View, TouchableHighlight, ScrollView, TextInput, Alert ,Platform } from 'react-native';
33
import JVerification from 'jverification-react-native'
44

55
var styles = StyleSheet.create({
@@ -54,24 +54,51 @@ class Button extends React.Component {
5454
// type Props = {};
5555

5656
export default class App extends React.Component {
57+
constructor(props){
58+
super(props)
59+
this.state = {token:''}
60+
}
61+
5762
render() {
5863
return (
5964
<View style={styles.container}>
6065
<Button title="init"
6166
onPress={() => JVerification.init({
62-
appKey: 'a1703c14b186a68a66ef86c1',
67+
appKey: 'your appkey',
6368
channel: 'the channel'
6469
})}/>
6570

6671
<Button title="getToken"
67-
onPress={() => JVerification.getToken((res) => {
68-
Alert.alert('token', JSON.stringify(res));
69-
})}/>
72+
onPress={() => {
73+
if(Platform.OS == "android"){
74+
JVerification.requestPermission(res => {
75+
if(res.code == 0){
76+
JVerification.getToken(res => {
77+
Alert.alert("token", JSON.stringify(res));
78+
if(res.code == 2000){
79+
this.setState({ token: res.content });
80+
}
81+
});
82+
}else{
83+
Alert.alert("requestPermission", JSON.stringify(res));
84+
}
85+
86+
});
87+
}else{
88+
JVerification.getToken(res => {
89+
Alert.alert("token", JSON.stringify(res));
90+
if (res.code == 2000) {
91+
this.setState({ token: res.content });
92+
}
93+
});
94+
}
95+
}
96+
}/>
7097

7198
<Button title="verifyNumber"
7299
onPress={() => JVerification.verifyNumber({
73-
number: 'the number',
74-
code: 'code'
100+
number: 'your number',
101+
token: this.state.token
75102
},(res) => {
76103
Alert.alert('token', JSON.stringify(res));
77104
})}/>

example/android/app/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,19 @@ android {
9898
buildToolsVersion rootProject.ext.buildToolsVersion
9999

100100
defaultConfig {
101-
applicationId "com.example"
101+
applicationId "com.test.josh"
102102
minSdkVersion rootProject.ext.minSdkVersion
103103
targetSdkVersion rootProject.ext.targetSdkVersion
104104
versionCode 1
105105
versionName "1.0"
106106
ndk {
107107
abiFilters "armeabi-v7a", "x86"
108108
}
109+
110+
manifestPlaceholders = [
111+
JPUSH_APPKEY: "your appkey", //在此替换你的APPKey
112+
JPUSH_CHANNEL: "developer-default" //应用渠道号
113+
]
109114
}
110115
splits {
111116
abi {
@@ -140,6 +145,8 @@ dependencies {
140145
implementation fileTree(dir: "libs", include: ["*.jar"])
141146
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
142147
implementation "com.facebook.react:react-native:+" // From node_modules
148+
implementation project(':jcore-react-native') // 添加 jcore 依赖
149+
implementation project(':jverification-react-native')
143150
}
144151

145152
// Run this once to be able to run the application with BUCK

example/android/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
</intent-filter>
2222
</activity>
2323
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
24+
25+
<meta-data android:name="JPUSH_CHANNEL" android:value="${JPUSH_CHANNEL}"/>
26+
<meta-data android:name="JPUSH_APPKEY" android:value="${JPUSH_APPKEY}"/>
27+
2428
</application>
2529

2630
</manifest>

example/android/app/src/main/java/com/example/MainApplication.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.Arrays;
1212
import java.util.List;
1313

14+
import cn.jpush.reactnativejvrification.JVerificationPackage;
15+
1416
public class MainApplication extends Application implements ReactApplication {
1517

1618
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@@ -22,7 +24,8 @@ public boolean getUseDeveloperSupport() {
2224
@Override
2325
protected List<ReactPackage> getPackages() {
2426
return Arrays.<ReactPackage>asList(
25-
new MainReactPackage()
27+
new MainReactPackage(),
28+
new JVerificationPackage()
2629
);
2730
}
2831

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "27.0.3"
6-
minSdkVersion = 16
6+
minSdkVersion = 23
77
compileSdkVersion = 27
88
targetSdkVersion = 26
99
supportLibVersion = "27.1.1"

example/android/settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
rootProject.name = 'example'
22

3-
include ':app'
3+
include ':app',':jcore-react-native',":jverification-react-native"
4+
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')
5+
project(':jverification-react-native').projectDir = new File(rootProject.projectDir, '../../android')

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1110
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -44,7 +43,6 @@
4443
7770D34F1F564C8FA64A72B7 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA79C8CC1E00442498E1DD93 /* CoreLocation.framework */; };
4544
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
4645
8C227EF7AD544A3799A640CC /* libRCTJVerificationModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F31CFCA33554CBA82C1D1B1 /* libRCTJVerificationModule.a */; };
47-
8D41481C99544EE6BAFFED94 /* libRCTJCoreModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA89089DAC94D4C9AF402DF /* libRCTJCoreModule.a */; };
4846
941EE17ED4E74CC4B1AE31FE /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C7B191EB11D415CA36A707F /* CoreTelephony.framework */; };
4947
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
5048
B4DDD78D60A8435D8F0E6687 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAE724DA621B43859243CEE9 /* AdSupport.framework */; };
@@ -55,6 +53,7 @@
5553
EEFF2D7E2B484AAAA1EBC58E /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F19EFD12E634069BA3AC0CE /* UserNotifications.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
5654
F19C1B2462E7418F9D407C79 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C92BDCBA1CA4798B9341B60 /* Foundation.framework */; };
5755
FC12C47A75504E22B712091D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41CDA630DA3E479CA9DEED90 /* Security.framework */; };
56+
6A31BFE1BA484F858017C465 /* libRCTJCoreModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B9F60C12EB9C4BCF8855E20D /* libRCTJCoreModule.a */; };
5857
/* End PBXBuildFile section */
5958

6059
/* Begin PBXContainerItemProxy section */
@@ -317,13 +316,6 @@
317316
remoteGlobalIDString = 62890E502190232500803A2B;
318317
remoteInfo = RCTJVerificationModule;
319318
};
320-
62890EF72190468400803A2B /* PBXContainerItemProxy */ = {
321-
isa = PBXContainerItemProxy;
322-
containerPortal = F912F8BE68544D67BDDB3EF3 /* RCTJCoreModule.xcodeproj */;
323-
proxyType = 2;
324-
remoteGlobalIDString = 6212E9B41F3990DC00BDF51A;
325-
remoteInfo = RCTJCoreModule;
326-
};
327319
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
328320
isa = PBXContainerItemProxy;
329321
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
@@ -377,7 +369,6 @@
377369
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
378370
6B7600CEE0B146BA8ADA88AD /* SystemConfiguration.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
379371
6C92BDCBA1CA4798B9341B60 /* Foundation.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
380-
6EA89089DAC94D4C9AF402DF /* libRCTJCoreModule.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTJCoreModule.a; sourceTree = "<group>"; };
381372
70FEF277EA1243DAA6B99D2D /* libresolv.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
382373
771F15DF00514C929EC67E9B /* CoreFoundation.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
383374
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
@@ -390,9 +381,10 @@
390381
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
391382
EDB804462F7B43D085880D28 /* RCTJVerificationModule.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTJVerificationModule.xcodeproj; path = "../node_modules/jverification-react-native/ios/RCTJVerificationModule.xcodeproj"; sourceTree = "<group>"; };
392383
F8C67ABAA50145FCA228FDC1 /* libsqlite3.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
393-
F912F8BE68544D67BDDB3EF3 /* RCTJCoreModule.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTJCoreModule.xcodeproj; path = "../node_modules/jcore-react-native/ios/RCTJCoreModule.xcodeproj"; sourceTree = "<group>"; };
394384
FA79C8CC1E00442498E1DD93 /* CoreLocation.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
395385
FAE724DA621B43859243CEE9 /* AdSupport.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
386+
47AABFD9C1794B46ACDD58FD /* RCTJCoreModule.xcodeproj */ = {isa = PBXFileReference; name = "RCTJCoreModule.xcodeproj"; path = "../node_modules/jcore-react-native/ios/RCTJCoreModule.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
387+
B9F60C12EB9C4BCF8855E20D /* libRCTJCoreModule.a */ = {isa = PBXFileReference; name = "libRCTJCoreModule.a"; path = "libRCTJCoreModule.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
396388
/* End PBXFileReference section */
397389

398390
/* Begin PBXFrameworksBuildPhase section */
@@ -436,7 +428,7 @@
436428
7770D34F1F564C8FA64A72B7 /* CoreLocation.framework in Frameworks */,
437429
2F266F61DEA74A889633735E /* libsqlite3.tbd in Frameworks */,
438430
C4317689B17843F9B8DBADCE /* MobileCoreServices.framework in Frameworks */,
439-
8D41481C99544EE6BAFFED94 /* libRCTJCoreModule.a in Frameworks */,
431+
6A31BFE1BA484F858017C465 /* libRCTJCoreModule.a in Frameworks */,
440432
);
441433
runOnlyForDeploymentPostprocessing = 0;
442434
};
@@ -631,14 +623,6 @@
631623
name = Products;
632624
sourceTree = "<group>";
633625
};
634-
62890EF42190468400803A2B /* Products */ = {
635-
isa = PBXGroup;
636-
children = (
637-
62890EF82190468400803A2B /* libRCTJCoreModule.a */,
638-
);
639-
name = Products;
640-
sourceTree = "<group>";
641-
};
642626
78C398B11ACF4ADC00677621 /* Products */ = {
643627
isa = PBXGroup;
644628
children = (
@@ -664,7 +648,7 @@
664648
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
665649
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
666650
EDB804462F7B43D085880D28 /* RCTJVerificationModule.xcodeproj */,
667-
F912F8BE68544D67BDDB3EF3 /* RCTJCoreModule.xcodeproj */,
651+
47AABFD9C1794B46ACDD58FD /* RCTJCoreModule.xcodeproj */,
668652
);
669653
name = Libraries;
670654
sourceTree = "<group>";
@@ -847,10 +831,6 @@
847831
ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */;
848832
ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
849833
},
850-
{
851-
ProductGroup = 62890EF42190468400803A2B /* Products */;
852-
ProjectRef = F912F8BE68544D67BDDB3EF3 /* RCTJCoreModule.xcodeproj */;
853-
},
854834
{
855835
ProductGroup = 62890EBC219039F500803A2B /* Products */;
856836
ProjectRef = EDB804462F7B43D085880D28 /* RCTJVerificationModule.xcodeproj */;
@@ -1140,13 +1120,6 @@
11401120
remoteRef = 62890EBF219039F500803A2B /* PBXContainerItemProxy */;
11411121
sourceTree = BUILT_PRODUCTS_DIR;
11421122
};
1143-
62890EF82190468400803A2B /* libRCTJCoreModule.a */ = {
1144-
isa = PBXReferenceProxy;
1145-
fileType = archive.ar;
1146-
path = libRCTJCoreModule.a;
1147-
remoteRef = 62890EF72190468400803A2B /* PBXContainerItemProxy */;
1148-
sourceTree = BUILT_PRODUCTS_DIR;
1149-
};
11501123
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
11511124
isa = PBXReferenceProxy;
11521125
fileType = archive.ar;
@@ -1317,7 +1290,6 @@
13171290
LIBRARY_SEARCH_PATHS = (
13181291
"$(inherited)",
13191292
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1320-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
13211293
);
13221294
OTHER_LDFLAGS = (
13231295
"-ObjC",
@@ -1345,7 +1317,6 @@
13451317
LIBRARY_SEARCH_PATHS = (
13461318
"$(inherited)",
13471319
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1348-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
13491320
);
13501321
OTHER_LDFLAGS = (
13511322
"-ObjC",
@@ -1438,7 +1409,6 @@
14381409
LIBRARY_SEARCH_PATHS = (
14391410
"$(inherited)",
14401411
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1441-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
14421412
);
14431413
OTHER_LDFLAGS = (
14441414
"-ObjC",
@@ -1474,7 +1444,6 @@
14741444
LIBRARY_SEARCH_PATHS = (
14751445
"$(inherited)",
14761446
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1477-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
14781447
);
14791448
OTHER_LDFLAGS = (
14801449
"-ObjC",
@@ -1509,7 +1478,6 @@
15091478
LIBRARY_SEARCH_PATHS = (
15101479
"$(inherited)",
15111480
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1512-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
15131481
);
15141482
OTHER_LDFLAGS = (
15151483
"-ObjC",
@@ -1544,7 +1512,6 @@
15441512
LIBRARY_SEARCH_PATHS = (
15451513
"$(inherited)",
15461514
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1547-
"\"$(SRCROOT)/$(TARGET_NAME)\"",
15481515
);
15491516
OTHER_LDFLAGS = (
15501517
"-ObjC",

example/package-lock.json

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"test": "jest"
88
},
99
"dependencies": {
10-
"jcore-react-native": "^1.2.11",
10+
"jcore-react-native": "^1.3.0",
11+
"jverification-react-native": "file:..",
1112
"react": "16.6.0-alpha.8af6728",
1213
"react-native": "^0.57.4"
1314
},

0 commit comments

Comments
 (0)