错误:插件'plugin'中未定义方法'methodName' - Phonegap 3.0 iOS

3
我正在尝试使用PhoneGap 3.0开发iOS应用程序。 该应用程序使用ShareKit插件和GAPlugin for PhoneGap,并且在使用PhoneGap 2.9时可以正常工作。 更新后,它可以编译,但当我尝试访问插件中的函数时,它会给我这个错误。
错误:插件'ShareKitPlugin'中未定义'method 'share:'。 2013-07-22 22:05:06.976-[CDVCommandQueue executePending] [Line 116] FAILED pluginJSON = [ "INVALID", "ShareKitPlugin", "share", [ "test", "http:\/\/www.test.com" ] ]
错误:插件'GAPlugin'中未定义'method 'initGA:'。 2013-07-22 22:05:06.977 -[CDVCommandQueue executePending] [Line 116] FAILED pluginJSON = [ "GAPlugin1900170756", "GAPlugin", "initGA", [ "UA-XXXXXX-11", 10 ] ]
3个回答

8
如果您在Phonegap 3.0中使用“旧”插件,则需要在插件方法的本地代码中编写hack。例如:
- (void)register:(CDVInvokedUrlCommand*)command
{
    self.callbackId = command.callbackId;
    NSArray *arguments = command.arguments;
    NSDictionary *options = [arguments objectAtIndex:0];

替代

- (void)register:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options
    self.callbackId = [arguments pop];

终于,在花费了将近一天的时间来解决这个问题之后 - 这个方法解决了它。谢谢。 - axel freudiger

7

GAPlugin目前不支持Phonegap 2.1.0引入的新插件签名。旧的插件签名在Phonegap/Cordova 3.0.0中已不再支持。

新的签名是:

- (void)myMethod:(CDVInvokedUrlCommand*)command; 

GAPlugin仍在使用:

  • (void) initGA:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

(详情请参见https://github.com/phonegap-build/GAPlugin/blob/master/src/ios/GAPlugin.h)。

ShareKit插件也是如此。


谢谢 floerkem,我已经相应地更新了两个插件,现在它们可以正常工作了。 - Mohamed Fasil

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接