罗广聪

contact 可读取电话了

@@ -133,6 +133,7 @@ android { @@ -133,6 +133,7 @@ android {
133 } 133 }
134 134
135 dependencies { 135 dependencies {
  136 + compile project(':react-native-contacts')
136 compile fileTree(dir: "libs", include: ["*.jar"]) 137 compile fileTree(dir: "libs", include: ["*.jar"])
137 compile "com.android.support:appcompat-v7:23.0.1" 138 compile "com.android.support:appcompat-v7:23.0.1"
138 compile "com.facebook.react:react-native:+" // From node_modules 139 compile "com.facebook.react:react-native:+" // From node_modules
@@ -3,6 +3,7 @@ package com.protectgod; @@ -3,6 +3,7 @@ package com.protectgod;
3 import android.app.Application; 3 import android.app.Application;
4 4
5 import com.facebook.react.ReactApplication; 5 import com.facebook.react.ReactApplication;
  6 +import com.rt2zz.reactnativecontacts.ReactNativeContacts;
6 import com.facebook.react.ReactNativeHost; 7 import com.facebook.react.ReactNativeHost;
7 import com.facebook.react.ReactPackage; 8 import com.facebook.react.ReactPackage;
8 import com.facebook.react.shell.MainReactPackage; 9 import com.facebook.react.shell.MainReactPackage;
@@ -22,7 +23,8 @@ public class MainApplication extends Application implements ReactApplication { @@ -22,7 +23,8 @@ public class MainApplication extends Application implements ReactApplication {
22 @Override 23 @Override
23 protected List<ReactPackage> getPackages() { 24 protected List<ReactPackage> getPackages() {
24 return Arrays.<ReactPackage>asList( 25 return Arrays.<ReactPackage>asList(
25 - new MainReactPackage() 26 + new MainReactPackage(),
  27 + new ReactNativeContacts()
26 ); 28 );
27 } 29 }
28 }; 30 };
1 rootProject.name = 'ProtectGod' 1 rootProject.name = 'ProtectGod'
  2 +include ':react-native-contacts'
  3 +project(':react-native-contacts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-contacts/android')
2 4
3 include ':app' 5 include ':app'
This diff is collapsed. Click to expand it.
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0"> 3 <plist version="1.0">
4 <dict> 4 <dict>
  5 + <key>NSContactsUsageDescription</key>
  6 + <string>是否允许访问通信录</string>
5 <key>CFBundleDevelopmentRegion</key> 7 <key>CFBundleDevelopmentRegion</key>
6 <string>en</string> 8 <string>en</string>
7 <key>CFBundleDisplayName</key> 9 <key>CFBundleDisplayName</key>
@@ -51,5 +53,7 @@ @@ -51,5 +53,7 @@
51 </array> 53 </array>
52 <key>UIViewControllerBasedStatusBarAppearance</key> 54 <key>UIViewControllerBasedStatusBarAppearance</key>
53 <false/> 55 <false/>
  56 + <key>LSApplicationCategoryType</key>
  57 + <string></string>
54 </dict> 58 </dict>
55 </plist> 59 </plist>
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 "dependencies": { 9 "dependencies": {
10 "react": "16.0.0-alpha.12", 10 "react": "16.0.0-alpha.12",
11 "react-native": "0.48.1", 11 "react-native": "0.48.1",
  12 + "react-native-contacts": "^1.0.2",
12 "react-native-easy-grid": "^0.1.15", 13 "react-native-easy-grid": "^0.1.15",
13 "react-native-swiper": "^1.5.11", 14 "react-native-swiper": "^1.5.11",
14 "react-navigation": "^1.0.0-beta.11" 15 "react-navigation": "^1.0.0-beta.11"
@@ -14,6 +14,7 @@ import { @@ -14,6 +14,7 @@ import {
14 } from "react-native"; 14 } from "react-native";
15 import { StackNavigator, TabNavigator } from "react-navigation"; 15 import { StackNavigator, TabNavigator } from "react-navigation";
16 import post from "../../utils/fetch"; 16 import post from "../../utils/fetch";
  17 +import Contacts from 'react-native-contacts';
17 18
18 export default class Customer extends Component { 19 export default class Customer extends Component {
19 constructor(props) { 20 constructor(props) {
@@ -43,6 +44,7 @@ export default class Customer extends Component { @@ -43,6 +44,7 @@ export default class Customer extends Component {
43 } 44 }
44 ] 45 ]
45 }; 46 };
  47 + this.getAllPhone = this.getAllPhone.bind(this);
46 } 48 }
47 componentWillMount() { 49 componentWillMount() {
48 this.getAsyncStorage(); 50 this.getAsyncStorage();
@@ -63,16 +65,17 @@ export default class Customer extends Component { @@ -63,16 +65,17 @@ export default class Customer extends Component {
63 phones.push(phone.number); 65 phones.push(phone.number);
64 }); 66 });
65 }); 67 });
66 - post( 68 + console.log("通信录",phones)
67 - "/spreader/rank/friends/contact", 69 + // post(
68 - { contact: phones }, 70 + // "/spreader/rank/friends/contact",
69 - res => { 71 + // { contact: phones },
70 - this.getRankData(); 72 + // res => {
71 - }, 73 + // this.getRankData();
72 - resErr => { 74 + // },
73 - Toast.show(resErr.cnmsg, Toast.error); 75 + // resErr => {
74 - } 76 + // Toast.show(resErr.cnmsg, Toast.error);
75 - ); 77 + // }
  78 + // );
76 } 79 }
77 }); 80 });
78 } 81 }
@@ -124,6 +127,7 @@ export default class Customer extends Component { @@ -124,6 +127,7 @@ export default class Customer extends Component {
124 } else { 127 } else {
125 { 128 {
126 /* navigate("CustomerEdit"); */ 129 /* navigate("CustomerEdit"); */
  130 + this.getAllPhone()
127 } 131 }
128 } 132 }
129 }} 133 }}
@@ -3548,6 +3548,10 @@ react-devtools-core@^2.5.0: @@ -3548,6 +3548,10 @@ react-devtools-core@^2.5.0:
3548 shell-quote "^1.6.1" 3548 shell-quote "^1.6.1"
3549 ws "^2.0.3" 3549 ws "^2.0.3"
3550 3550
  3551 +react-native-contacts@^1.0.2:
  3552 + version "1.0.2"
  3553 + resolved "http://registry.npm.taobao.org/react-native-contacts/download/react-native-contacts-1.0.2.tgz#58b3b0572e3972a320c731ff639091b013a3c4b0"
  3554 +
3551 react-native-dismiss-keyboard@1.0.0: 3555 react-native-dismiss-keyboard@1.0.0:
3552 version "1.0.0" 3556 version "1.0.0"
3553 resolved "http://registry.npm.taobao.org/react-native-dismiss-keyboard/download/react-native-dismiss-keyboard-1.0.0.tgz#32886242b3f2317e121f3aeb9b0a585e2b879b49" 3557 resolved "http://registry.npm.taobao.org/react-native-dismiss-keyboard/download/react-native-dismiss-keyboard-1.0.0.tgz#32886242b3f2317e121f3aeb9b0a585e2b879b49"