tschoffelen / react-native-email-link

📭 Open an email client from React Native (for 'magic link' type functionality).
MIT License
394 stars 70 forks source link

Can't catch error if no Email client on Android #104

Closed pastoreli closed 2 years ago

pastoreli commented 2 years ago

I'm trying to handle with no email app exception, but it's not work on Android, because its never fall the .catch and .then always return null as result

Alert: Its work fine in IOS

openInbox({
 title: 'Title',
 message: 'Message',
}).catch((err: EmailException) => {
 if (err.message === 'No email apps available') {
  alert('No email');
  } else {
   alert('Default error');
  }
 });
tschoffelen commented 2 years ago

I think this information is indeed currently not passed back from the native bit of the Android integration to the javascript side. Definitely something we could add I think.

andrew-blackwood commented 2 years ago

I think this information is indeed currently not passed back from the native bit of the Android integration to the javascript side. Definitely something we could add I think.

This would be much appreciated. The lack of throwing an error when no email client is found on Android is potentially a blocker for me right now in using this library.

tschoffelen commented 2 years ago

Anyone able to do a PR for this?

andrew-blackwood commented 2 years ago

Anyone able to do a PR for this?

Yes, I can. I have already created the fix in a forked repo - will create the PR later today.