'How to send an email attachment from a webview

I am converting a phonegap app to run in a standard webview.

One of the features that we are losing is the ability to send an email with an attachment.

In standard html we can code:

<a href="mailto:[email protected]?subject=free chocolate">example</a>

In phonegap we code this:

 cordova.plugins.email.open({
        subject:     'Quote',
        attachments: ['base64:Quote.pdf//'+base64]
    }); 
}

The phonegap method allows for adding an attachment.

I want to do the same thing in webview.

In iOS webview is called WKWebView. In Android webview is called WebView.

I am asking this question for both iOS and Android as I suspect there is some solution that.

I already know what html does not support this so answers telling me it is not possible are not helpful.

Phonegap is doing it so it must be possible. I am thinking there must be a way to add a function available to javascript.

We code in Kotlin on Android and Swift on iOS.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source