Ionic-native: EmailComposer isAvailable error - TypeError: n.getPlugin(...).isAvailable is not a function

Created on 22 Jun 2019  路  6Comments  路  Source: ionic-team/ionic-native

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:

In my function, I make a call to isAvailable function on the native email plugin

submitBugReport() {
this.emailComposer.isAvailable()
   .then(......)
   .catch(e => {
      .....
   });
....
}

the isAvailable function always results in rejection. The error object, is the following

{"stack":"TypeError: n.getPlugin(...).isAvailable is not a function\n at http://localhost/build/vendor.js:1:614647\n at new t (http://localhost/build/polyfills.js:3:21506)\n at e.isAvailable (http://localhost/build/vendor.js:1:614553)\n at e.value [as isAvailable] (http://localhost/build/vendor.js:1:189959)\n at l.submitBugReport (http://localhost/build/2.js:1:20520)\n at Object.handleEvent (http://localhost/build/2.js:1:14966)\n at Object.handleEvent (http://localhost/build/vendor.js:1:38487)\n at Object.handleEvent (http://localhost/build/vendor.js:1:48308)\n at xt (http://localhost/build/vendor.js:1:18175)\n at http://localhost/build/vendor.js:1:23647","message":"n.getPlugin(...).isAvailable is not a function","__zone_symbol__currentTask":{}}

Expected behavior:

Enter the then() function

Steps to reproduce:

Call isAvailable on the emailComposer class

Related code:

insert any relevant code here

Other information:

Ionic Framework - 3.9.2
cordova-plugin-email-composer - 0.9.2
@ionic-native/email-composer - 4.17.0 & 4.20.0

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

   ionic (Ionic CLI)  : 4.12.0 (C:\Users\User\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   cordova (Cordova CLI) : 9.0.0 ([email protected])
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 22 other plugins)

System:

   Android SDK Tools : 25.2.5 (C:\Users\User\AppData\Local\Android\android-sdk)
   NodeJS            : v8.12.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.4.1
   OS                : Windows 10

Most helpful comment

Since version 0.9 of EmailComposer, they changed isAvailable and broke it into two functions hasClient and hasAccount

Version 0.9.0 (not yet released)

  • [__change__]: Replace isAvailable through hasClient and hasAccount.

https://github.com/katzer/cordova-plugin-email-composer/commit/9f19ee5a8f27b18fce861f3412601dc84bf2f2e5

@ionic-native haven't updated the definitions.

All 6 comments

Since version 0.9 of EmailComposer, they changed isAvailable and broke it into two functions hasClient and hasAccount

Version 0.9.0 (not yet released)

  • [__change__]: Replace isAvailable through hasClient and hasAccount.

https://github.com/katzer/cordova-plugin-email-composer/commit/9f19ee5a8f27b18fce861f3412601dc84bf2f2e5

@ionic-native haven't updated the definitions.

Thanks for the info @maxpaj

Any news ?

In the meantime I'm doing this...

    <plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
  providers: [
    AndroidPermissions,
 ]

declare var cordova : any;

    await this.platform.ready();
    if (this.platform.is("cordova")) {
      await this.androidPermissions.requestPermissions(
        [
          this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE,
          this.androidPermissions.PERMISSION.GET_ACCOUNTS
        ]
      );

      const attach = attachments.map(attachment=>{
        return '' + attachment.replace('file://','')
      });

      cordova.plugins.email.open({
          to:          [to], // email addresses for TO field
          //cc:          Array, // email addresses for CC field
          //bcc:         Array, // email addresses for BCC field
          attachments: attach, // file paths or base64 data streams
          subject:    title, // subject of the email
          body:       text, // email body
          isHtml:    true  // indicats if the body is HTML or plain text (primarily iOS)
      }, ()=>{

      });
    }

Since version 0.9 of EmailComposer, they changed isAvailable and broke it into two functions hasClient and hasAccount

Version 0.9.0 (not yet released)

  • [change]: Replace isAvailable through hasClient and hasAccount.

katzer/cordova-plugin-email-composer@9f19ee5

@ionic-native haven't updated the definitions.

How do you use those functions to achieve the same effect?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyleap picture kyleap  路  4Comments

ajcrites picture ajcrites  路  3Comments

ghost picture ghost  路  3Comments

danbucholtz picture danbucholtz  路  3Comments

wwallace picture wwallace  路  4Comments