-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
74 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"--> | ||
``` | ||
|
||
3. specify your qq appid and appkey in `node_modules/react-native-sharesdk/android/src/main/assets/ShareSDK.xml` | ||
|
||
```xml | ||
<!-- ShareByAppClient标识是否使用微博客户端分享,默认是false --> | ||
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,5 @@ android/app/libs | |
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
|
||
.vscode |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters