0

我正在研究Ionic app并且我正在使用appsFlyer cordova插件,但不知何故,每当用户第一次打开应用程序(我的意思是每当应用程序第一次安装在设备中时)它都会出现错误和其他后续过程中断。

错误 :

2016-04-13 11:38:44.047 WotNow[1730:35993] bool _WebTryThreadLock(bool), 0x7fd5450b4170: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
1   0x10878b70b WebThreadLock
2   0x1016d9b04 -[UIWebView stringByEvaluatingJavaScriptFromString:]
3   0x1008c6720 -[AppsFlyerPlugin onConversionDataReceived:]
4   0x100a46a8c __53-[AppsFlyerTracker handleConversionDataWithDelegate:]_block_invoke182
5   0x1093c6b49 __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke
6   0x1093d90f2 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke
7   0x1056b6630 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
8   0x1055f1805 -[NSBlockOperation main]
9   0x1055d4725 -[__NSOperationInternal _start:]
10  0x1055d4336 __NSOQSchedule_f
11  0x1063143eb _dispatch_client_callout
12  0x1062fa82c _dispatch_queue_drain
13  0x1062f9d4d _dispatch_queue_invoke
14  0x1062fc996 _dispatch_root_queue_drain
15  0x1062fc405 _dispatch_worker_thread3
16  0x1066514de _pthread_wqthread
17  0x10664f341 start_wqthread

在 xcode 中,它将下面的代码突出显示为错误。

XCODE 错误代码:

-(void)onConversionDataReceived:(NSDictionary*) installData {
    NSError *error;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:installData
                                            options:0
                                            error:&error];
    if (jsonData) {
        NSString *JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];
        [[super webView] stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"javascript:window.plugins.appsFlyer.onInstallConversionDataLoaded(%@)", JSONString]];

    } else {
        NSLog(@"%@",error);
    }
}

我不太了解Objective-ciOS错误,所以如果有人能告诉我应该在哪里查看以及应该添加什么代码来解决此类问题,那将非常有帮助。

4

2 回答 2

0

AppsFlyer 发布了针对该问题的修复程序。从https://github.com/AppsFlyerSDK/PhoneGap进行更新 您也可以在 github 上提交问题。

于 2016-04-13T20:25:05.947 回答
0

尝试这个

 -(void)onConversionDataReceived:(NSDictionary*) installData {
            NSError *error;
            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:installData
                                                    options:0
                                                    error:&error];
            if (jsonData) {
                NSString *JSONString = [[NSString alloc] initWithBytes:[jsonData bytes] length:[jsonData length] encoding:NSUTF8StringEncoding];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{

     [[super webView] stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"javascript:window.plugins.appsFlyer.onInstallConversionDataLoaded(%@)", JSONString]]; 
});

            } else {
                NSLog(@"%@",error);
            }
        }
于 2016-04-13T06:50:06.750 回答