Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Error : not_available in Android 13 with several emailing app #198

Open
Ezzine-Smichi opened this issue Jul 8, 2023 · 2 comments
Open

Comments

@Ezzine-Smichi
Copy link

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?

@joshua-revolutions
Copy link

joshua-revolutions commented Jul 11, 2023

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.

@Ezzine-Smichi
Copy link
Author

Ezzine-Smichi commented Jul 11, 2023

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");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants