react-native-mail
react-native-mail copied to clipboard
Error : not_available in Android 13 with several emailing app
When I launch email opening from my react native application, this package returns the following message "not_available". Faced with this problem, I put this portion of code as a comment
if (list == null || list.size() == 0) { callback.invoke("not_available"); return; }
and everything works fine again. Does this solution work for you? If not, is there another solution for this problem?
Inside RNMailModule.java I commented out
/*if (list == null || list.size() == 0) {
callback.invoke("not_available");
return;
}
}*/
and now it works. This requires patching the node_modules itself.
this solution with device have only the gmail app doesn't return anything, so the problem of this package is to get access to the gmail app. inside RNMailModule.java, I replace this code:
if (list == null || list.size() == 0) { callback.invoke("not_available"); return; } }
with this code:
` if (list == null || list.size() == 0) { Intent intent = manager.getLaunchIntentForPackage("com.google.android.gm"); if (intent != null) { String chooserTitle = "Send Mail";
if (options.hasKey("customChooserTitle") && !options.isNull("customChooserTitle")) {
chooserTitle = options.getString("customChooserTitle");
}
Intent chooser = Intent.createChooser(i, chooserTitle);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
reactContext.startActivity(chooser);
} catch (Exception ex) {
callback.invoke("error");
}
} else {
callback.invoke("not_available");
return;
}
}`
The idea is to force checkout the gmail app with this line if the list is empty :
Intent intent = manager.getLaunchIntentForPackage("com.google.android.gm");