katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
344 stars 333 forks source link

Android -- Open Default App with Attachment, without Android Chooser #297

Closed AbhishekJoshi closed 5 years ago

AbhishekJoshi commented 6 years ago

I have a single mail app on my device, set as default Gmail.

Are we able to send an email, with an attachment (pdf) to the default mail app, without having an app chooser/selector?

I currently only get one app in my chooser.

cepm-nate commented 6 years ago

Typically that's handled on the OS. There should be a 'Always use X' button when you pick an app.

AbhishekJoshi commented 6 years ago

Example off one of my burner phones. Samsung S5.

Android 7 LG IV Pad Tablet, and Android 6 Nexus 5 had same results.

This is running latest off Github, and only has a single email app and it is set as a default. Confirmed via Settings and a Default App checker off the store. Attaching a dummy pdf. App is vanilla, nothing fancy going on.

I'll probably investigate the Java source -- I created this issue as it different behaviour on equivalent path of iOS. On iOS, if the default Mail App is set (yes, I'm aware it cannot be changed), we can open it directly. On Android, even if a single app is available, the OS is popping up the Chooser.

This does need seem like it is operating as intended.

TheDuc commented 6 years ago

I also have this same problem. Also, the 'mailto:' app behaves differently then a mailto link from within Chrome. When I use mailto also 'Whatsapp', 'save to drive' and 'bluetooth' appear for example, but they don't when using mailto in browser.

TheDuc commented 6 years ago

I see now that ACTION_SENDTO intent doesn't support sending attachments (https://medium.com/@cketti/android-sending-email-using-intents-3da63662c58f) In the same article is written to not use Intent.createChooser(). Without that the default mailapp will be opened.

BKHines commented 5 years ago

Is there any way to add an option to ignore chooser? I changed my local plugin to implement the issue referenced above and I was able to select GMAIL as default and then it opened automatically every time. The only code I had to change was to declare draft with final and then send draft into the startActivityResult like this:

final Intent draft = impl.getDraft(props); ... cordova.getThreadPool().execute(new Runnable() { public void run() { cordova.startActivityForResult(plugin, draft, 0); } });

Could you make an update to the plugin to toggle this line of code via another email composer option?

katzer commented 5 years ago

I've merged the PR!

BKHines commented 5 years ago

I"m not sure if I'm doing something wrong but I removed the plugin and then re-added it but I still get the old code. Some way to force the CLI to get the latest code?

katzer commented 5 years ago

@BKHines I haven't released a new version yet. If you want to test the new code then you have to install the plugin with the git url - see the installation notes in the README.

BKHines commented 5 years ago

Ah, gotcha. Sorry about that, didn't even notice the same version number. Thanks @katzer.

On Wed, Nov 14, 2018, 9:58 AM Sebastián Katzer <notifications@github.com wrote:

@BKHines https://github.com/BKHines I haven't released a new version yet. If you want to test the new code then you have to install the plugin with the git url - see the installation notes in the README.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-email-composer/issues/297#issuecomment-438690988, or mute the thread https://github.com/notifications/unsubscribe-auth/AgG1N3eyK8hRhp_WAQKluk4Ap0qUqiVpks5uvC-YgaJpZM4S9gY4 .

BKHines commented 5 years ago

With the latest version (0.9.1), I seem to be getting a chooser again, this time only with Samsung Email and gmail. Browsing the code, it looks like it's still sending the draft into the activity instead of a chooser, but no matter what I do, it still opens the "Open With" dialog, both on a device or an emulator. Was this change reverted with some other method? Was there a newly added option I missed to ignore the chooser?

If not, it could possibly be my device. It's a new phone (S9+) so it's entirely possible even though the default email app is gmail, it may not be set up correctly. I'm having another developer check it on their device as well to verify they're also seeing it. It had previously worked for them and as far as I know, they're running the same device they were with the previous version where chooser was not showing.

katzer commented 5 years ago

What version of Android?

BKHines commented 5 years ago

8.0.0. I'm wondering if it's something Samsung is forcing to try to make you use their email client. I've reached out to another developer who has a pixel 2 xl but I haven't heard back.