katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
345 stars 336 forks source link

On Android 11, emailComposer.open() do nothing nor call error #371

Closed catapulte2 closed 2 years ago

catapulte2 commented 2 years ago

Hi, Thanks for your job. It works perfectly on previous versions of Android but for information on Android 11, emailcomposer.open(email) do nothing. It don't call .then nor error or catch functions call. For moment I bypass this like this :

var ok : boolean = false; this.emailComposer.open(email).then(result=>{
// Call on all release before Android 11 ok = true; },e=>{ //never call if android 11 }).catch(e=>{ //never call if android 11 }) setTimeout(() => { if(!ok){ //my call to Window.open with mailto function for android 11 devices } },3000);

If you want me to make tests modifications on my code, your welcome.

Best regards,

Eric

jfoclpf commented 2 years ago

The callback has no error parameter and the open method does not return any Promise, the docs are clear on that

cordova.plugins.email.open({
    from:       String, // sending email account (iOS only)
    to:          Array, // email addresses for TO field
    cc:          Array, // email addresses for CC field
    bcc:         Array, // email addresses for BCC field
    attachments: Array, // file paths or base64 data streams
    subject:    String, // subject of the email
    body:       String, // email body
    isHtml:    Boolean  // indicats if the body is HTML or plain text (primarily iOS)
}, () => {
  console.log('Finished')
})
Topiya commented 2 years ago

@catapulte2 Did you find any solution yet? I am facing a same issue.

jfoclpf commented 2 years ago

@Topiya did you try the code I posted here in the thread?

With me it works on Android 11

catapulte2 commented 2 years ago

Hi Topiya, We finally stop using Ionic and Cordova because we spent too much time searching for stability bugs. I don't think it come from the Cordova plugin itself but from all the compile integration wich make more and more it's live alone. Sometime plugins work, sometime not... Nobody know why. ;-( Regards,

Topiya commented 2 years ago

The callback has no error parameter and the open method does not return any Promise, the docs are clear on that

cordova.plugins.email.open({
    from:       String, // sending email account (iOS only)
    to:          Array, // email addresses for TO field
    cc:          Array, // email addresses for CC field
    bcc:         Array, // email addresses for BCC field
    attachments: Array, // file paths or base64 data streams
    subject:    String, // subject of the email
    body:       String, // email body
    isHtml:    Boolean  // indicats if the body is HTML or plain text (primarily iOS)
}, () => {
  console.log('Finished')
})

@jfoclpf I am getting below error while using above code. ERROR TypeError: Cannot read property 'email' of undefined

catapulte2 commented 2 years ago

In "normal" situation, this is just because Plugin is not correctly installed or define. Try Remove it and reinstall it. If you are using Ionic when we had this case, often solution was to remove all platform the re-install. Example : ionic cordova platfrom rm android; ionic cordova platform add android. Be sure to make a backup before in case of...

jfoclpf commented 2 years ago

@Topiya as @catapulte2 referred you have a problem with installation, just check on the console the result of typeof cordova.plugins.email. It should be an object.

Topiya commented 2 years ago

Thank you. I have re-added android platform. Now error is gone but main issue still persist, App crashes on cordova.plugins.email.open function call.

jfoclpf commented 2 years ago

@Topiya what exact error is shown on console.log ?

when you type in console dev tools typeof cordova.plugins.email and typeof cordova.plugins.email.open what do you see?