有人可以解释一下如何添加插件吗?
我将m和h文件添加到Plugins目录
然后在config.xml中添加以下行:
<plugin name="DeviceDetails" value="DeviceDetails" />
并在我的html中包含了js文件
我现在如何实际使用此插件?我怎么知道它有效?
我目前正在做:(coffeescript)
try
console.log DeviceDetails()
catch e
console.log e
并在xCode中收到此错误:
[LOG] {"line":24,"sourceURL":"file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/media/js/index.js","stack":"onDeviceReady@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/media/js/index.js:24\nfire@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/cordova-2.6.0.js:683\n@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/cordova-2.6.0.js:221\n[native code]"}
这是插件js文件:
;(function(cordova) {
function DeviceDetails() {}
DeviceDetails.prototype.getDetails = function(callback) {
cordova.exec(callback, callback, "DeviceDetails", "getDeviceDetails", [])
}
DeviceDetails.prototype.getUUID = function(callback) {
cordova.exec(callback, callback, "DeviceDetails", "getDeviceUUID", [])
}
if (!window.plugins) window.plugins = {}
window.plugins.deviceDetails = new DeviceDetails()
})(window.cordova || window.Cordova || window.PhoneGap);