简体   繁体   中英

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

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.

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 {};
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM