@@ -80,21 +80,6 @@ public void mail(ReadableMap options, Callback callback) {
8080 ReadableArray ccRecipients = options .getArray ("ccRecipients" );
8181 i .putExtra (Intent .EXTRA_CC , readableArrayToStringArray (ccRecipients ));
8282 }
83- if (options .hasKey ("attachments" ) && !options .isNull ("attachments" )) {
84- ReadableArray r = options .getArray ("attachments" );
85- int length = r .size ();
86- ArrayList <Uri > uris = new ArrayList <Uri >();
87- for (int keyIndex = 0 ; keyIndex < length ; keyIndex ++) {
88- ReadableMap clip = r .getMap (keyIndex );
89- if (clip .hasKey ("path" ) && !clip .isNull ("path" )){
90- String path = clip .getString ("path" );
91- File file = new File (path );
92- Uri u = Uri .fromFile (file );
93- uris .add (u );
94- }
95- }
96- i .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
97- }
9883
9984 if (options .hasKey ("bccRecipients" ) && !options .isNull ("bccRecipients" )) {
10085 ReadableArray bccRecipients = options .getArray ("bccRecipients" );
@@ -110,6 +95,7 @@ public void mail(ReadableMap options, Callback callback) {
11095 if (clip .hasKey ("path" ) && !clip .isNull ("path" )) {
11196 String path = clip .getString ("path" );
11297 File file = new File (path );
98+ file .setReadable (true , false );
11399 if (file .exists ()) {
114100 uris .add (Uri .fromFile (file ));
115101 }
@@ -118,12 +104,6 @@ public void mail(ReadableMap options, Callback callback) {
118104 i .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
119105 }
120106
121- i .setType (null ); // If we're using a selector, then clear the type to null. I don't know why this is needed, but it doesn't work without it.
122- final Intent restrictIntent = new Intent (Intent .ACTION_SENDTO );
123- Uri data =
Uri .
parse (
"mailto:[email protected] " );
124- restrictIntent .setData (data );
125- i .setSelector (restrictIntent );
126-
127107 PackageManager manager = reactContext .getPackageManager ();
128108 List <ResolveInfo > list = manager .queryIntentActivities (i , 0 );
129109
@@ -145,6 +125,7 @@ public void mail(ReadableMap options, Callback callback) {
145125 try {
146126 reactContext .startActivity (chooser );
147127 } catch (Exception ex ) {
128+ callback .invoke ("error" );
148129 }
149130
150131 }
0 commit comments