Skip to content

Commit

Permalink
1.编写readme
Browse files Browse the repository at this point in the history
2.优化例子
  • Loading branch information
lihaodeveloper committed Jan 31, 2017
1 parent f5c5f90 commit e316bab
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 111 deletions.
Binary file modified .DS_Store
Binary file not shown.
71 changes: 58 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
1.0.3版
加入qq 登录 for android
# react-native-sharesdk
share sdk for react-native

## install

安装: npm i react-native-sharesdk --save
`npm i react-native-sharesdk --save`

链接: react-native link
## link

Android:
1.需要在node_modules/react-native-sharesdk/android/build.gradle中替换你申请到的qq appid
manifestPlaceholders = [
`react-native link react-native-sharesdk`

### android

1. specify your qq AppId in `node_modules/react-native-sharesdk/android/build.gradle`

```xml
defaultConfig {
...
manifestPlaceholders = [
QQ_APP_ID: "100371282", //qq AppId
]

]
}
```

2. specify your sharesdk appkey in `node_modules/react-native-sharesdk/android/src/main/assets/ShareSDK.xml`

2.需要在node_modules/react-native-sharesdk/android/src/main/assets/ShareSDK.xml中替换你申请到的share sdk的 appkey和 qq appid,appkey。
<ShareSDK
```xml
<ShareSDK
AppKey = "androidv1101"/> <!-- 修改成你在sharesdk后台注册的应用的appkey"-->
```

<QQ
3. specify your qq appid and appkey in `node_modules/react-native-sharesdk/android/src/main/assets/ShareSDK.xml`

```xml
<!-- ShareByAppClient标识是否使用微博客户端分享,默认是false -->
<QQ
Id="7"
SortId="7"
AppId="100371282"
AppKey="aed9b0303e3ed1e27bae87c33761161d"
ShareByAppClient="true"
Enable="true" />
```

## usage

```
...
import { NativeModules } from 'react-native'
const {MobLogin} = NativeModules
...
_onPressLogin() {
MobLogin.loginWithQQ().then((data) => {
console.log('token: ', data.token)
console.log('user_id: ', data.user_id)
console.log('user_name: ', data.user_name)
console.log('user_gender: ', data.user_gender)
console.log('user_icon: ', data.user_icon)
}, (code, mes) => {
console.log(code, mes)
})
}
3.参照例子开始哈啤
render() {
return (
<View style={styles.container}>
<TouchableOpacity style={styles.qqlogin} onPress={()=>this._onPressLogin()}>
<Text style={{fontSize: 18, color: 'black'}}>QQLogin</Text>
</TouchableOpacity>
</View>
)
}
Binary file modified android/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ android/app/libs
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots

.vscode
78 changes: 0 additions & 78 deletions example/.vscode/.react/debuggerWorker.js

This file was deleted.

2 changes: 1 addition & 1 deletion example/.vscode/launchReactNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
try {
var path = require("path");
var Launcher = require("/Users/cc/.vscode/extensions/vsmobile.vscode-react-native-0.2.5/out/debugger/launcher.js").Launcher;
new Launcher("/Users/cc/npmworkspace/ShareSdkExample", "/Users/cc/npmworkspace/ShareSdkExample").launch();
new Launcher("/Users/cc/npmworkspace/React-Native-ShareSdk/example", "/Users/cc/npmworkspace/React-Native-ShareSdk/example").launch();
} catch (e) {
throw new Error("Unable to launch application. Try deleting .vscode/launchReactNative.js and restarting vscode.");
}
32 changes: 13 additions & 19 deletions example/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
StyleSheet,
Text,
View,
TouchableOpacity,
NativeModules
} from 'react-native';

Expand All @@ -31,15 +32,9 @@ export default class ShareSdkExample extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions} onPress={() => this._onPressLogin()}>
QQ登录
</Text>
<TouchableOpacity style={styles.qqlogin} onPress={()=>this._onPressLogin()}>
<Text style={{fontSize: 18, color: 'black'}}>QQLogin</Text>
</TouchableOpacity>
</View>
);
}
Expand All @@ -52,16 +47,15 @@ const styles = StyleSheet.create({
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
qqlogin:{
width: 150,
height: 60,
borderColor: 'red',
borderWidth: StyleSheet.hairlineWidth,
borderRadius: 12,
justifyContent: 'center',
alignItems: 'center'
}
});

AppRegistry.registerComponent('ShareSdkExample', () => ShareSdkExample);

0 comments on commit e316bab

Please sign in to comment.