0

我的工作Ionic app,我使用appsFlyer科爾多瓦插件,但不知何故,每當用戶打開應用程序的第一次(我的意思是,每當應用程序被安裝首次在設備)它給錯誤和其他下面的過程中斷。科爾多瓦appsFlyer程序崩潰的第一次

錯誤:

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錯誤,所以這將是更有益的,如果任何人都可以告訴我,我應該在哪裏看,應該怎麼代碼應該怎麼添加來解決這樣的問題。

+0

它的一個線程相關的問題一個UIKit方法,從一個線程而不是你的主線程,這是不允許的。 – AnshaD

+0

@AnshaD是否有任何解決辦法或我需要更改代碼? –

+0

dispatch_async(dispatch_get_main_queue(),^ { //在此處執行您的代碼 }); – AnshaD

回答

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); 
      } 
     } 
+0

不工作,仍然收到崩潰問題 –

相關問題