用于Windows Phone 8的LiveTile插件Cordova 3.3

问题描述:

我试图将LiveTile插件(找到here)添加到我的Clean Cordova 3.3项目中。但我似乎无法让它工作。它适用于链接的指令,但使用Cordova 2.0.0。 我碰到下面的打印输出,当我尝试添加一个新的瓷砖:用于Windows Phone 8的LiveTile插件Cordova 3.3

 An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary 
     A first chance exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll 
     An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary 
     Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'. 
     Failed to deserialize Cordova.Extension.Commands.LiveTiles+LiveTilesOptions with JSON value :: ["System.Collections.Generic.Dictionary`2[System.String,System.Object]","LiveTiles963855178"] 
     A first chance exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL 
     An exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL but was not handled in user code 
     A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll 
     An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary 
     ERROR: Exception in ProcessCommand :: Exception has been thrown by the target of an invocation. 
     ERROR: failed to InvokeMethodNamed :: createSecondaryTile on Object :: LiveTiles 
     The thread 0xbac has exited with code 259 (0x103). 
     Error occurred: Invalid action 

与科尔多瓦的这个新版本中添加不同的插件或者是LiveTile插件根本不兼容了?

这可能是一个愚蠢的问题,但由于文档太穷,很难将任何问题称为愚蠢的。 但是我现在已经设法解决了这个问题,并且在别人遇到同样问题的机会下,我会试着解释我做了什么。

首先我发现this LiveTiles插件的实现,这个插件似乎比问题中的更近。我没有通过Visual Studio创建一个新项目,而是使用了CLI。

phonegap create hello com.example.hello HelloWorld 

然后我使用plugman根据上面的链接安装插件。

plugman install --project . --platform wp8 --plugin com.risingj.cordova.livetiles 

现在我浏览一下我的文件,看看发生了什么。

config.xml中 - 一些此外

<?xml version='1.0' encoding='utf-8'?> 
    <widget> 
     <access origin="*" /> 
     <feature name="LiveTiles"> 
      <param name="wp-package" value="LiveTiles" /> 
     </feature> 
    </widget> 

生成一个新文件:cordova_plugins.js与以下内容的WWW文件夹:

cordova.define('cordova/plugin_list', function(require, exports, module) { 
module.exports = [ 
    { 
     "file": "plugins/livetiles.js", 
     "id": "com.risingj.cordova.livetiles.livetiles", 
     "clobbers": [ 
      "LiveTiles" 
     ] 
    } 
]; 
module.exports.metadata = 
// TOP OF METADATA 
{ 
    "com.risingj.cordova.livetiles": "0.1.0" 
} 
// BOTTOM OF METADATA 
}); 

我添加了这些文件到科尔多瓦Visual Studio项目,它的工作!所以我猜如果添加一个新的插件,这是需要的。

你需要这样做:

cordova plugin add path/to/your/plugin 

它会做所有的东西。