forked from moorinl/react-native-share-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (28 loc) · 759 Bytes
/
index.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
'use strict';
var ShareUtil = require('./utils/share');
var ShareActions = {
/**
* @param {Object} options
* @param {String} options.url
* @param {String} options.message
* @param {String} options.subject
* @param {String} title
* @return {Promise}
*/
share: function(options, title) {
// Wrap result in a Promise, for consistent Android and iOS Promise usage
return new Promise(function(resolve, reject) {
if (!options.url) {
reject(new Error("Url attribute is required"));
}
ShareUtil.share(options, title)
.then(function(result) {
resolve(result);
})
.catch(function(error) {
reject(error);
});
});
}
};
module.exports = ShareActions;