Capacitor: Uncaught (in promise) Keyboard does not have web implementation.

Created on 1 Sep 2019  ·  3Comments  ·  Source: ionic-team/capacitor

I am wrapping my plugin calls in try/catches to avoid promise rejections being uncaught, but this doesn't seem to be working:

try {
  const { Keyboard } = Plugins
  Keyboard.setAccessoryBarVisible({ isVisible: true })
} catch (error) {
  // Keyboard isn't available on web so we need to swallow the error
}

Uncaught (in promise) Keyboard does not have web implementation.

Affected platform

  • [ ] Android
  • [ ] iOS
  • [ ] electron
  • [x] web

OS of the development machine

  • [ ] Windows
  • [x] macOS
  • [ ] linux

Other information:

Capacitor version: 1.1.1

node version: v10.15.3

npm version: 6.4.1

Most helpful comment

This is how I fixed this issue

let Keyboard;
  if (Capacitor.platform !== "web") {
    Keyboard = Plugins.Keyboard
}

All 3 comments

This is how I fixed this issue

let Keyboard;
  if (Capacitor.platform !== "web") {
    Keyboard = Plugins.Keyboard
}

Thank you so much! I wasn't aware of Capacitor.platform and it's use has solved a lot of other conditional headaches for me!

You can also use Capacitor.isPluginAvailable

Was this page helpful?
0 / 5 - 0 ratings