-
Notifications
You must be signed in to change notification settings - Fork 61
/
app.js
88 lines (78 loc) · 2.28 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* react-native-share/login
* update by Songlcy 2017-12-02
*/
import React, { Component } from 'react';
import {
Text,
View,
NativeModules,
StyleSheet,
AppRegistry
} from 'react-native';
import UShare from './share/share'
import SharePlatform from './SharePlatform'
export default class ReactNativeShare extends Component {
/**
* 第三方分享
* 参数:标题、分享内容、分享链接、图片、平台、分享结果回调
*/
_share() {
UShare.share('标题','内容', 'http://baidu.com','http://dev.umeng.com/images/tab2_1.png', SharePlatform.QQ,
(message) => {
// message: 分享成功、分享失败、取消分享
// TODO ...
});
}
/**
* 第三方登录
* 参数:登录平台、登录结果回调
* 'userId: ' 用户id
'accessToken: token
'userName: ' 用户昵称
'userGender: ' 用户性别
'userAvatar: ' 用户头像
*/
_getUserInfo() {
UShare.authLogin(SharePlatform.QQ, (result) => {
// code: 0成功、1失败、2取消
if(result.code === 0) {
console.log('授权登录成功:' +
'userId: ' + result.uid +
'accessToken: ' + result.accessToken +
'userName: ' + result.userName +
'userGender: ' + result.userGender +
'userAvatar: ' + result.userAvatar
);
} else {
// TODO ...
}
});
}
render() {
return (
<View style={ styles.container }>
<Text style={ styles.title } onPress={ this._share.bind(this) }>
第三方分享
</Text>
<Text style={ styles.title } onPress={ this._getUserInfo.bind(this) }>
第三方登录
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
title: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
AppRegistry.registerComponent('ReactNativeShare', () => ReactNativeShare);