我正在使用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-c
和iOS
错误,所以如果有人能告诉我应该在哪里查看以及我应该添加什么代码以解决此类问题,那将会非常有用。
答案 0 :(得分: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);
}
}
答案 1 :(得分:0)
AppsFlyer针对该问题发布了修补程序..来自https://github.com/AppsFlyerSDK/PhoneGap的更新 您也可以在github上提交问题。