xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 506 forks source link

[Bug][Android11] Email.ComposeAsync throws Xamarin.Essentials.FeatureNotSupportedException #1907

Closed takla21 closed 2 years ago

takla21 commented 2 years ago

Description

Email.ComposeAsync() throws Xamarin.Essentials.FeatureNotSupportedException on android 11 devices.

{Xamarin.Essentials.FeatureNotSupportedException: Specified method is not supported.
  at Xamarin.Essentials.Email.ComposeAsync (Xamarin.Essentials.EmailMessage message) [0x00007] in d:\a\1\s\Xamarin.Essentials\Email\Email.shared.cs:21 
  at Xamarin.Essentials.Email.ComposeAsync (System.String subject, System.String body, System.String[] to) [0x00000] in d:\a\1\s\Xamarin.Essentials\Email\Email.shared.cs:16 

Steps to Reproduce

try
{
    await Email.ComposeAsync(subject, body, to);
}
catch (Exception e)
{
    this.Log().LogError(e, "error");
}

Expected Behavior

It should open the client mail app.

Actual Behavior

It throws Xamarin.Essentials.FeatureNotSupportedException on android 11 devices.

Basic Information

vincentcastagna commented 2 years ago

Fixed this by adding missing intent flags in AndroidManifest. Weirdly, it was working with some other Android 11 devices, such as Samsung and others

<queries>
  <intent>
    <action android:name="android.intent.action.SENDTO" />
    <data android:scheme="mailto" />
  </intent>
</queries>
takla21 commented 2 years ago

well adding the flags does indeed fix the issue. I'm closing this one.

nzaugg commented 2 years ago

I think this exception is very poorly named. If it was something more like "Android Intent Missing From Manifest" or something like that then it's a better clue of where to start looking. The exception thrown here sounds like it doesn't work because the feature is not implemented in the library.