Open MartinZikmund opened 4 years ago
Option # 1 is prefererable from a point of view of compatibility with existing code - certainly clean-up afterwards would be a must.
For option # 2, Uno.UI.Toolkit
would be the place for it.
For that matter they're not mutually exclusive, both options could exist side-by-side.
@davidjohnoliver I am only worried that when we do both, microsoft/microsoft-ui-xaml#1 will be immediately discoverable and the developer will never find out that microsoft/microsoft-ui-xaml#2 is the more efficient choice (unless they explicitly check the docs, but you cannot check docs for everything 😀)
Valid, but I think the same problem would exist if we were to only implement # 2: people will see that the UWP method is NotImplemented and they'll figure that it's just not supported.
Discoverability is hard!
@davidjohnoliver Okay - what about doing both and add a comment to microsoft/microsoft-ui-xaml#1 that suggests using microsoft/microsoft-ui-xaml#2 instead. Potentially there could be a Roslyn Analyzer in the future as well, with such a suggestion.
Last question - when to do the backup cleanup in case it, for some reason, fails after the e-mail is sent? Startup could work, but we want to launch as fast as possible. It could run asynchronously though. And the deletion after sending should fail only occasionally anyway.
Sure, some remarks in the xml doc of # 1 drawing attention to # 2 (and vice versa) would make sense.
For the backup cleanup - maybe do it the next time the app tries to send an email attachment? Agreed we wouldn't want to slow down launch for this case.
One thing I am worried - if using the API is a one time thing, we would have a dead weight adding to the app size forever there 😕
Any update on this?
Xamarin.Essential
's implementation of this API has the somewhat narky behaviour of just silently falling back to mail-URIs should the device's provided API be unavailable.
If I am not mistaken Uno currently does the same.
if (MFMailComposeViewController.CanSendMail)
{
await ComposeEmailWithMFAsync(message);
}
else
{
await ComposeEmailWithMailtoUriAsync(message);
}
For plain E-Mails this is mostly a non.issue, but since mail-URIs do not support attachments they just end up getting scrapped while letting the API's consumer know nothing of this.
(On iOS this can become quite the nuisance as MFMailComposeViewController.CanSendMail
may return false despite the Mail App being apparently configured correctly. I could reproduce this on two devices with an uneven mix of different iOS- and device-versions, third party mail apps and a lot of tough luck.)
Hence my suggestion is to not adopt the same mistake and let the user know of that case, perhaps through throwing an exception when an attachment is passed but the fallback initiated.
A possible workaround is to use MAUI essentials, until uno supports EmailManager
.
What would you like to be added:
Uno Platform implementation of
EmailManager
currently does not support e-mail attachments. The problem is that Andorid and iOS support file-based attachments only, however UWP API is fully based on streams. There would be two options:ApplicationData.Current.TemporaryFolder
, as that one should get cleaned up by the system automaticallyWhy is this needed:
To send files with e-mail. It is often used for sending crash-dumps.
For which Platform: