capacitor-runtime.js:81 ERROR TypeError: Cannot read property 'open' of undefined at Email.open

Created on 4 Jul 2019  ·  6Comments  ·  Source: ionic-team/capacitor

I am trying to use email plugin from teamhive for capacitor - ionic 4 project
but it throws me an error 'Cannot read property 'open' of undefined at Email.open'
Initially, it was giving me same error for hasPermission() so I removed it and directly used email.open()

Most helpful comment

For 3rd party plugins in Android, you need to register the plugin in the MainActivity.java so you can use it (it doesn't auto registers as on iOS).
The plugin was missing those instructions, so I've sent a PR to their repo.
https://github.com/TeamHive/capacitor-email/pull/2

All 6 comments

Same problem here.

'E/Capacitor/Plugin/Console: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'requestPermission' of undefined"

My console.log statement below outputs I/Capacitor/Plugin/Console: this.email = {}

email: Email;

  constructor() { }

  ngOnInit() {
    this.email = new Email();
    console.log('this.email = ' + JSON.stringify(this.email));
  }

  async sendEmail() {

    try {
      await this.email.hasPermission();
    } catch (e) {
      await this.email.requestPermission();
    }

The github repo for capacitor-email doesn't allow issues to be raised directly :(

Tumbleweeds...

My conclusion is it's not safe to move to Capacitor as there are too few plugins and they are unsupported.

What's the repo of the plugin?
Can you provide a sample app using it?

Looks like a bug on the plugin, but would like to double check.

Repo: https://github.com/TeamHive/capacitor-email
Sample project (based on the demo code in the plugin): https://github.com/AndrWeisR/email-bug

When you run this sample project and click the "Open Email" button, you see an exception:

2019-07-16 10:32:48.981 10331-10389/email.bug E/Capacitor/Plugin/Console: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'requestPermission' of undefined
    TypeError: Cannot read property 'requestPermission' of undefined
        at Email.requestPermission (http://localhost/home-home-module.js:50:27)
        at HomePage.<anonymous> (http://localhost/home-home-module.js:2598:57)
        at step (http://localhost/vendor.js:96316:23)
        at Object.next (http://localhost/vendor.js:96297:53)
        at http://localhost/vendor.js:96290:71
        at new ZoneAwarePromise (http://localhost/polyfills.js:3272:29)
        at Module.__awaiter (http://localhost/vendor.js:96286:12)
        at HomePage.push../src/app/home/home.page.ts.HomePage.openEmail (http://localhost/home-home-module.js:2586:63)
        at HomePage.push../src/app/home/home.page.ts.HomePage.open (http://localhost/home-home-module.js:2655:14)
        at Object.eval [as handleEvent] (ng:///HomePageModule/HomePage.ngfactory.js:24:27)

For 3rd party plugins in Android, you need to register the plugin in the MainActivity.java so you can use it (it doesn't auto registers as on iOS).
The plugin was missing those instructions, so I've sent a PR to their repo.
https://github.com/TeamHive/capacitor-email/pull/2

@jcesarmobile Did you get an answer or figure out the config path? Please share it here if you have. Thanks.

Was this page helpful?
0 / 5 - 0 ratings