cordova appsFlyer app crash first time

623 views Asked by At

I am working on Ionic app and I am using appsFlyer cordova plugin, but somehow whenever user open app for the first time ( i mean whenever app is installed for the first time in device ) it giving error and other following process breaks.

Error :

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

And in xcode it highlight below code as error.

XCODE Error Code :

-(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);
    }
}

I am not much aware of Objective-c and iOS errors so it would be much helpful if anyone can tell me where should i look and what should code should i add to resolve such problem.

2

There are 2 answers

0
golts On

AppsFlyer released a fix for that issue..go and update from https://github.com/AppsFlyerSDK/PhoneGap You can also submit issues on github.

0
Anshad Rasheed On

Try this

 -(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);
            }
        }