Meteor/Cordova: is there a way to activate a atmosphere js package only on android?

53 views Asked by At

The amazing 255kb:cordova-keyboard package works perfectly, but because of some bug that I could not figure out it prevents me from building for iphone. How can I add a package only for android? Is this possible? I only need this package to handle some situations where users close the keyboard with the Android hardware back button.

1

There are 1 answers

3
Mozfet On

You can use Meteor's dynamic imports together with platform detection.

function isAndroid() {
  return navigator.userAgent.toLowerCase().indexOf("android") > -1;
}

async function getAndroidLib() {
  if(isAndroid) {
    return await import('path/to/lib');
  }
  else {
    return {};
  }
}