Search code examples
cordovaios9cordova-plugins

Cordova Ionic email plugin not working on iOS 9 due to URL


I'm using the email composer plugin for my ionic application and I'm running into a problem on iOS 9 where I am unable to work with an external email application. I've tried adding the following to plist since it is a url scheme but that doesn't seem to have helped.

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>mailto</string>
    </array>

Error xcode gives:

2015-10-06 22:10:45.037 NSP[1830:29571] -canOpenURL: failed for URL: "mailto:[email protected]" - error: "(null)"
2015-10-06 22:10:45.044 NSP[1830:29571] -canOpenURL: failed for URL: "mailto:[email protected]" - error: "(null)"
2015-10-06 22:10:45.047 NSP[1830:29571] -canOpenURL: failed for URL: "mailto:[email protected]" - error: "(null)"

Yes, it was 3 errors on a single call. Here is the call code:

$cordovaEmailComposer.isAvailable().then(function () {
                $cordovaEmailComposer.open({
                    to: [], // email addresses for TO field
                    cc: [], // email addresses for CC field
                    bcc: [], // email addresses for BCC field
                    attachments: [], // file paths or base64 data streams
                    subject: item.name, // subject of the email
                    body: item.name + " download link: " + item.link, // email body (for HTML, set isHtml to true)
                    isHtml: false, // indicats if the body is HTML or plain text
                }, function () {
                    //console.log('email view dismissed');
                }, this);
            }, function () { //Not available
                MessageBox.ShowAlert("Unavailible", "Email is currently unavailable on this platform");
            });

Is there any way to fix this? It works great on android, and earlier versions of iOS or is it a plugin problem that I can't fix? Everything is updated. Possible workarounds or other plugins to make this work? I tried the solution here but I don't think this is related to my issue.


Solution

  • I had the exact same problem.

    After adding LSApplicationQueriesSchemes and having no luck, I tried on an actual device and it did work properly. It just isn't working in the simulator.

    A quick way to add LSApplicationQueriesSchemes is with:

    cordova plugin add cordova-plugin-queries-schemes