forked from lucasferreira/react-native-send-intent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
116 lines (113 loc) · 4.37 KB
/
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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @providesModule SendIntentAndroid
*/
var { Platform, NativeModules } = require("react-native");
var RNSendIntentAndroid = NativeModules.SendIntentAndroid || {};
var SendIntentAndroid = {
TEXT_PLAIN: Platform.OS === "android" ? RNSendIntentAndroid.TEXT_PLAIN : "text/plain",
TEXT_HTML: Platform.OS === "android" ? RNSendIntentAndroid.TEXT_HTML : "text/html",
sendText(config) {
if ("title" in config && config.title != null && config.title.length > 0) {
RNSendIntentAndroid.sendTextWithTitle(config.title, config.text, config.type || "text/plain");
} else {
RNSendIntentAndroid.sendText(config.text, config.type || "text/plain");
}
},
sendPhoneCall(phoneNumber, phoneAppOnly = false) {
RNSendIntentAndroid.sendPhoneCall(phoneNumber, phoneAppOnly);
},
sendPhoneDial(phoneNumber, phoneAppOnly = false) {
RNSendIntentAndroid.sendPhoneDial(phoneNumber, phoneAppOnly);
},
sendSms(phoneNumber, body = null) {
RNSendIntentAndroid.sendSms(phoneNumber, body);
},
addCalendarEvent(config) {
RNSendIntentAndroid.addCalendarEvent(
config.title,
config.description,
config.startDate,
config.endDate,
config.recurrence,
config.location,
config.isAllDay || false
);
},
isAppInstalled(packageName) {
return RNSendIntentAndroid.isAppInstalled(packageName);
},
installRemoteApp(uri, saveAs) {
return RNSendIntentAndroid.installRemoteApp(uri, saveAs);
},
openCalendar() {
RNSendIntentAndroid.openCalendar();
},
sendMail(mail, subject = "", body = "") {
RNSendIntentAndroid.sendMail(mail, subject, body);
},
openChooserWithOptions(options, title) {
RNSendIntentAndroid.openChooserWithOptions(options, title);
},
openChooserWithMultipleOptions(options, title) {
RNSendIntentAndroid.openChooserWithMultipleOptions(options, title);
},
openMaps(query) {
RNSendIntentAndroid.openMaps(query);
},
openCamera() {
RNSendIntentAndroid.openCamera();
},
openMapsWithRoute(query, mode) {
RNSendIntentAndroid.openMapsWithRoute(query, mode);
},
shareTextToLine(options) {
RNSendIntentAndroid.shareTextToLine(options);
},
shareImageToInstagram(type, mediaPath) {
RNSendIntentAndroid.shareImageToInstagram(type, mediaPath);
},
openSettings(settingsName) {
RNSendIntentAndroid.openSettings(settingsName);
},
getVoiceMailNumber() {
return RNSendIntentAndroid.getVoiceMailNumber();
},
getPhoneNumber() {
return RNSendIntentAndroid.getPhoneNumber();
},
openApp(packageName, extras) {
return RNSendIntentAndroid.openApp(packageName, extras || {});
},
/** Creates an ACTION_VIEW Intent for the given package with the given data, optional mimetype and extras.
* The extras are an object containing String, or other objects of the following format:
* { type: "int", value: 4 }
* Other possible types are int, short, byte, char, long and float.
*/
openAppWithData(packageName, dataUri, mimeType, extras) {
return RNSendIntentAndroid.openAppWithData(packageName, dataUri, mimeType, extras || {});
},
/**
* This method follows the chrome intent syntax: https://developer.chrome.com/multidevice/android/intents.
*
* Opens intent with package name defined in the dataUri field.
* When intent cannot be resolved, open the URL in browser_fallback_url in the mobile's browser.
* @param {string} dataUri - the intent url. Looks like: `intent://www.spm.com/qrlogin#Intent;scheme=https;package=example.package;S.browser_fallback_url=https://www.spm.com/download;end`.
* @returns {Promise<boolean>} true if app or fallback URL is opened, false otherwise.
*/
openChromeIntent(dataUri) {
return RNSendIntentAndroid.openChromeIntent(dataUri);
},
openFileChooser(options, title) {
return RNSendIntentAndroid.openFileChooser(options, title);
},
openFilePicker({type="*/*",title="Choose File"}, callback) {
return RNSendIntentAndroid.openFilePicker({type,title}, callback);
},
openEmailApp() {
RNSendIntentAndroid.openEmailApp();
},
openDownloadManager() {
RNSendIntentAndroid.openDownloadManager();
}
};
module.exports = SendIntentAndroid;