-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ios.js
93 lines (86 loc) · 2.01 KB
/
index.ios.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
89
90
91
92
93
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var NativeRNShare = require('NativeModules').SaiModule;
var Share = {
test: function() {
NativeRNShare.test();
},
open: function(options) {
NativeRNShare.open(options);
}
};
var Mailer = require('NativeModules').RNMail;
var {
AppRegistry,
StyleSheet,
Text,
View,
AlertIOS,
} = React;
var TouchableHighlight = require('TouchableHighlight');
var example = React.createClass({
onShare: function() {
Share.open({
share_text: "Hola mundo",
share_URL: "http://google.cl",
title: "Share Link"
},function(e) {
console.log(e);
});
/*
// in iOS without callback
Share.open({
share_text: "Hola mundo",
share_URL: "http://google.cl",
title: "Share Link"
});
*/
},
onMail:function(){
Mailer.mail({
subject: 'need help',
recipients: ['[email protected]'],
body: '',
attachment: {
path: '', // The absolute path of the file from which to read data.
type: '', // Mime Type: jpg, png, doc, ppt, html, pdf
name: '', // Optional: Custom filename for attachment
}
}, (error, event) => {
if(error) {
AlertIOS.alert('Error', 'Could not send mail. Please send a mail to [email protected]');
}else{
AlertIOS.alert('success','mail');
}
});
},
render: function() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={this.onMail}>
<Text style={styles.instructions}>
Share
</Text>
</TouchableHighlight>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('SaiCustomModule', () => example);