Search code examples
androidionic-frameworkionic3cordova-plugins

Ionic email composer crash on android 11


I had implemented the cordova-plugin-email-composer in my project and it works well before that but after upgrading to [email protected] the app crashed when trigger the this.emailcomposer.open(email).

Only android 11 was crashing and android 8 works fine. When I change back to [email protected], both android 8 and 11 works fine.

https://github.com/katzer/cordova-plugin-email-composer/issues/350

I found someone having the same problem. So I wonder is a bug or we need to write up something on the config.xml


Solution

  • I found the solution for the ionic email composer crashing issue. In the URL link below was the documentation for the changes in android 11.

    https://developer.android.com/about/versions/11/behavior-changes-all#share-content-uris

    Need to add the below code in the config.xml under android

    <config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
                        <uses-permission android:name="android.permission.FLAG_GRANT_READ_URI_PERMISSION" />
                    </config-file>
        <config-file parent="/manifest/queries" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
                    <package android:name="com.google.android.gm" />
                    <package android:name="com.microsoft.office.outlook" />
                    <package android:name="com.yahoo.mobile.client.android.mail" />
                    <intent>
                        <action android:name="android.support.customtabs.action.CustomTabsService" />
                    </intent>
                </config-file>