Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的phonegap应用的iOS插件曾经运行过一次。当应用程序再次启动时,它不会';在我进入后台并返回应用程序之前,我无法工作_Ios_Iphone_Plugins_Cordova - Fatal编程技术网

我的phonegap应用的iOS插件曾经运行过一次。当应用程序再次启动时,它不会';在我进入后台并返回应用程序之前,我无法工作

我的phonegap应用的iOS插件曾经运行过一次。当应用程序再次启动时,它不会';在我进入后台并返回应用程序之前,我无法工作,ios,iphone,plugins,cordova,Ios,Iphone,Plugins,Cordova,我用PhoneGap 2.8.1制作了iPhone应用程序,最近我遇到了一个奇怪的问题: 我已经编写了一个插件,它在设备上存储一些应用程序秘密,对给定的数据进行散列(使用这些秘密),然后将散列返回给JS 当我在安装后第一次运行我的应用程序时,一切正常。 但当我再次启动它时,应用程序在我的插件方法启动之前(或者可能在启动时)冻结。 第三方插件开始前加载ok,但当涉及到我的插件-什么都没有发生 Xcode控制台上没有,weinre控制台上没有。无效的没有错误异常,没有来自本机代码的日志。 当我试图从

我用PhoneGap 2.8.1制作了iPhone应用程序,最近我遇到了一个奇怪的问题: 我已经编写了一个插件,它在设备上存储一些应用程序秘密,对给定的数据进行散列(使用这些秘密),然后将散列返回给JS

当我在安装后第一次运行我的应用程序时,一切正常。 但当我再次启动它时,应用程序在我的插件方法启动之前(或者可能在启动时)冻结。 第三方插件开始前加载ok,但当涉及到我的插件-什么都没有发生

Xcode控制台上没有,weinre控制台上没有。无效的没有错误异常,没有来自本机代码的日志。 当我试图从weinre控制台手动运行一些本机方法时,也没有发生任何事情

但当我点击主页按钮打开应用程序背景并返回时,一切都神奇地开始工作了


有人有类似的问题吗?有什么解决办法吗?线索?

我有一个散列数据的方法,该数据将在请求中发送到我的API。我是这样使用它的:

window.plugins.protocol.hamac data, (results) =>
    # work with results
- (void)hamac:(CDVInvokedUrlCommand*)command {
    NSLog(@"HAMAC STARTED!");
    CDVPluginResult* pluginResult = nil;

    @try {
        NSDictionary* data = [command.arguments objectAtIndex:0];

        if (data != nil) {
            // prepare string to be hashed

            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: @{
                                                                                                        @"status": @YES,
                                                                                                        @"h": [self sha1:[NSString stringWithFormat:@"%@", stringToHash]
                                                                                                        }];
        } else {
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary: @{
                                                                                                           @"status": @NO,
                                                                                                           @"error": @"No data!"
                                                                                                           }];
        }
    } @catch (NSException* e) {
        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary: @{
                                                                                                       @"status": @NO,
                                                                                                       @"error": @"Failed to hash data"
                                                                                                       }];
    }

    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
本机代码如下所示:

window.plugins.protocol.hamac data, (results) =>
    # work with results
- (void)hamac:(CDVInvokedUrlCommand*)command {
    NSLog(@"HAMAC STARTED!");
    CDVPluginResult* pluginResult = nil;

    @try {
        NSDictionary* data = [command.arguments objectAtIndex:0];

        if (data != nil) {
            // prepare string to be hashed

            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: @{
                                                                                                        @"status": @YES,
                                                                                                        @"h": [self sha1:[NSString stringWithFormat:@"%@", stringToHash]
                                                                                                        }];
        } else {
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary: @{
                                                                                                           @"status": @NO,
                                                                                                           @"error": @"No data!"
                                                                                                           }];
        }
    } @catch (NSException* e) {
        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary: @{
                                                                                                       @"status": @NO,
                                                                                                       @"error": @"Failed to hash data"
                                                                                                       }];
    }

    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

你确定你在“deviceready”被触发后正在使用插件吗?是的,我的整个应用程序在deviceready事件被触发后启动。你能显示一些代码吗?比如你是如何使用你的插件的?你找到了解决方法吗?我面临着一个类似的问题,但是使用Phonegap的媒体和对话框插件,我在网上找不到任何关于这个的信息。哦,是的,结果证明我在JS中有错误(使用不存在的方法)。这个错误阻止了一切。所以检查你的JS!