Anybody who succeeded in adding "Email Composer" Cordova plugin to Ionic 5 project (for Android12)?

Viewed 327

I have created a simple Ionic 5 app and would like to add the functionality that would allow sending emails (including those scheduled). I have tried the https://ionicframework.com/docs/native/email-composer but found myself stuck with this supporting Android 12. Is there anybody who succeeded?

2 Answers

After searching around for a while, I came across Simon Grimm's video in which he added this exact plugin to an Ionic/Capacitor project. Prior to finding the video I was having trouble figuring out how to add the Android configuration properly to AndroidManifest.xml. When running ionic cap sync, I got a warning that I needed to add the following to AndroidManifest.xml:

<intent>
  <action android:name="android.intent.action.SENDTO"/>
  <data android:scheme="mailto"/>
</intent>

But there was no documentation on how exactly to do this. The solution was in the video:

<manifest ...>

    <queries>
        <intent>
            <action android:name="android.intent.action.SENDTO"/>
            <data android:scheme="mailto"/>
        </intent>
    </queries>

</manifest>

The intent element needs to be placed inside <queries>, which should be placed directly within the <manifest> tag (and not inside <application> or <activity>). After doing this, I was able to get the email composer to open up on Android 12 with Gmail.

Reference: https://www.youtube.com/watch?v=AF0jnmbbpbE

Related