Import Keyboard depending on device

Hello everybody,

I’m facing an issue in my current development with Ionic 3.
I first developped a desktop application which is working very well, but soon after i started to compile the application for IOS and ANDROID.

The problem i have is that i want to load the Keyboard component only when i run the mobile application (not in desktop browser). Obviously, if i try to load the Keyboard component in a web browser i got the message “Error: No provider for Keyboard!”.

Is there any way to load a component depending on the device ?

Something like :
if (‘cordova’)) {
import { Keyboard } from ‘@ionic-native/keyboard’;

Thanks a lot for the help !

If the error you’re getting is “Error: No provider for Keyboard!” then the issue isn’t related to the browser.

You need to import Keyboard into the providers section in app.module.ts.

After that it’ll work fine in the browser and on mobile.

Maybe this article will help you:

Thank you for your answers :wink:
Importing Keyboard to provided did the trick !

Don’t forget to ‘like’ or mark as ‘solution’ where appropriate.