我想在我的应用程序中包含Ionic Keyboard插件。我在Stack Overflow上发了几篇帖子,根据Idan的一个答案,他建议将Ionic Keyboard Plugin Classes直接添加到IBM MobileFirst Platform Foundation 6.3项目中,就像我们在添加插件时一样。
有没有人这样做过?我尝试过一次,但它不起作用。
我做的事情:
在iOS环境中的config.xml文件中添加了以下条目。
<feature name="Keyboard">
<param name="ios-package" value="IonicKeyboard" onload="true" />
</feature>
尝试使用课程hide-on-keyboard-show
。
<div class="hide-on-keyboard-open">
<div id="google-map"></div>
</div>
但它没有用,所以我假设键盘插件无法正常工作。
答案 0 :(得分:3)
要将IonicKeyboard
添加到MobileFirst 6.3(以受支持的方式),请按照documentation中的说明进行操作:
在config.xml文件中声明插件。
<feature name="Keyboard">
<param name="ios-package" onload="true" value="IonicKeyboard"/>
</feature>
在JavaScript代码中使用cordova.exec()API。
// added the cordova plugin definition in wlCommonInit(), as recommended by other answers I read (can't remember where),
// because the cordova event `deviceready` is fired and handled internally by MobileFirst
function wlCommonInit() {
// copied module id from https://github.com/driftyco/ionic-plugin-keyboard/blob/master/plugin.xml
cordova.define("com.ionic.keyboard.keyboard", function(require, exports, module) {
// copied code from https://github.com/driftyco/ionic-plugin-keyboard/blob/master/www/keyboard.js
var argscheck = require('cordova/argscheck'),
utils = require('cordova/utils'),
exec = require('cordova/exec');
var Keyboard = function() {
};
Keyboard.hideKeyboardAccessoryBar = function(hide) {
exec(null, null, "Keyboard", "hideKeyboardAccessoryBar", [hide]);
};
Keyboard.close = function() {
exec(null, null, "Keyboard", "close", []);
};
Keyboard.show = function() {
exec(null, null, "Keyboard", "show", []);
};
Keyboard.disableScroll = function(disable) {
exec(null, null, "Keyboard", "disableScroll", [disable]);
};
/*
Keyboard.styleDark = function(dark) {
exec(null, null, "Keyboard", "styleDark", [dark]);
};
*/
Keyboard.isVisible = false;
module.exports = Keyboard;
});
// Manually-register custom plugin
if (window.cordova && !window.cordova.plugins) {
window.cordova.plugins = {};
}
// Do this instead of `clobbers` definition in native/www/default/worklight/cordova_plugins.js
window.cordova.plugins.Keyboard = cordova.require('com.ionic.keyboard.keyboard');
}
创建将在iOS中本机运行的插件类。 插件执行所需的操作并调用在调用cordova.exec()期间指定的JavaScript回调方法。
IonicKeyboard.h
IonicKeyboard.m
UIWebViewExtension.h
UIWebViewExtension.m
YourProject/apps/yourAppName/iphone/native/Classes/
答案 1 :(得分:0)
我能做到这一点的唯一方法是使用克里斯在问题中给出的解决方案。链接附件。 (它在某种程度上是一种黑客行为) Add custom cordova plugin to IBM Worklight 6.1
但这个解决方案存在严重缺陷。每次发生mfp构建时,它都会覆盖cordova_plugins.js文件和plugins文件夹。