Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added callback with null error to notify if a mail is send for android #185

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion android/src/main/java/com/chirag/RNMail/RNMailModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import android.os.Build;

/**
* NativeModule that allows JS to open emails sending apps chooser.
Expand Down Expand Up @@ -127,7 +128,7 @@ public void mail(ReadableMap options, Callback callback) {
PackageManager manager = reactContext.getPackageManager();
List<ResolveInfo> list = manager.queryIntentActivities(i, 0);

if (list == null || list.size() == 0) {
if ((list == null || list.size() == 0) && Build.VERSION.SDK_INT < 33) {
callback.invoke("not_available");
return;
}
Expand All @@ -136,6 +137,7 @@ public void mail(ReadableMap options, Callback callback) {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
reactContext.startActivity(i);
callback.invoke();
} catch (Exception ex) {
callback.invoke("error");
}
Expand All @@ -151,6 +153,7 @@ public void mail(ReadableMap options, Callback callback) {

try {
reactContext.startActivity(chooser);
callback.invoke();
} catch (Exception ex) {
callback.invoke("error");
}
Expand Down