You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TODO: place your license here and we'll include it in the module distribution
1
+
Copyright (c) 2025 Douglas Alves
2
+
3
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This module solves a critical limitation in Titanium SDK when sharing images on Android 7.0+ (API 24+). Modern Android versions require the use of `content://` URIs through FileProvider instead of `file://` URIs for security reasons. While Titanium SDK provides intent-based sharing capabilities, it lacks native FileProvider support, making image sharing problematic with apps like WhatsApp, Telegram, and email clients.
9
+
This module solves a limitation in Titanium SDK when sharing images and videos on Android 7.0+ (API 24+). Modern Android versions require the use of `content://`URIs through FileProvider instead of `file://`URIs for security reasons. While Titanium SDK provides intent-based sharing capabilities, it lacks native FileProvider support, making media sharing problematic with apps like WhatsApp, Telegram, and email clients.
10
10
11
-
`ti.android.share` bridges this gap by providing a simple JavaScript API that handles all the complexity of FileProvider configuration, URI generation, and secure file sharing.
11
+
`ti.android.share`bridges this gap by providing a simple JavaScript API that handles all the complexity of FileProvider configuration, URI generation, and secure file sharing for both images and videos.
12
12
13
13
## Features
14
14
15
-
- Share images from URLs, Resources, Blobs, or file paths
16
-
- Automatic image download from remote URLs
17
-
- Automatic FileProvider URI generation
18
-
- Support for text and image combination sharing
19
-
- Optional callback to handle share results (success, cancelled, or error)
20
-
- Works with WhatsApp, Telegram, Email, and all Android share targets
21
-
- Compatible with Titanium SDK 13.x and modern Android versions
15
+
- Share text, images and videos from URLs, Resources, Blobs, or file paths
16
+
- Automatic media type detection (image vs video)
17
+
- Automatic media download from remote URLs
18
+
- Support for popular video formats: MP4, MOV, AVI, 3GP, MKV, WEBM, FLV, M4V
19
+
- Automatic FileProvider URI generation
20
+
- Support for text and media combination sharing
21
+
- File size validation and warnings (100MB limit for downloads)
22
+
- Optional callback to handle share results (success, cancelled, or error)
23
+
- Works with WhatsApp, Telegram, Email, and all Android share targets
24
+
- Compatible with Titanium SDK 13.x and modern Android versions
22
25
23
26
## Requirements
24
27
@@ -59,48 +62,72 @@ The module will use `com.yourcompany.yourapp.fileprovider` as the FileProvider a
The module will automatically download the image in the background before sharing. If the download fails, it will share text only (or notify via callback if provided).
108
+
The module will automatically download the media in the background before sharing. If the download fails, it will share text only (or notify via callback if provided).
97
109
98
110
```javascript
111
+
// Share image from url
99
112
ShareModule.share({
100
113
message:"Check out this amazing photo!",
101
114
subject:"Photo from the web",
102
115
image:"https://www.example.com/photos/sunset.jpg"
103
116
});
117
+
118
+
// Share video from url
119
+
ShareModule.share({
120
+
message:"Watch this awesome video!",
121
+
subject:"Video to share",
122
+
media:"https://www.example.com/videos/demo.mp4",
123
+
callback:function(e) {
124
+
if (e.success) {
125
+
Ti.API.info("Video shared successfully!");
126
+
} else {
127
+
Ti.API.error("Share failed: "+e.message);
128
+
}
129
+
}
130
+
});
104
131
```
105
132
106
133
### Share text only
@@ -144,13 +171,16 @@ Opens the Android share dialog with the specified content.
144
171
-`options` (Object): Configuration object with the following properties:
145
172
-`message` (String, optional): Text content to share
146
173
-`subject` (String, optional): Subject line for sharing (used by email apps)
147
-
-`image` (String|TiBlob, optional): Image to share. Can be:
148
-
-**URL** (e.g., `"https://example.com/photo.jpg"`) - Will be downloaded automatically
149
-
- Path to resource file (e.g., `/images/photo.jpg`)
-`media` (String|TiBlob, optional): Media file to share (images or videos). Can be: - **URL** (e.g., `"https://example.com/video.mp4"`) - Will be downloaded automatically - Path to resource file (e.g., `/videos/demo.mp4` or `/images/photo.jpg`) - Path from applicationDataDirectory - TiBlob object (from file read, camera, video recorder, etc.)
175
+
-`image` (String|TiBlob, optional): **Deprecated** - Use `media` instead. Still supported for backward compatibility
152
176
-`callback` (Function, optional): Callback function to receive share result
0 commit comments