From baa2172eca62eab057ab3bd43f433c0c928751d6 Mon Sep 17 00:00:00 2001 From: Jason Roth Date: Tue, 5 Sep 2017 14:26:45 -0400 Subject: [PATCH] removed CDVJSON and fixes for latest cordova --- src/ios/OverAppBrowser.m | 47 ++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/ios/OverAppBrowser.m b/src/ios/OverAppBrowser.m index 584cf84..dfc1762 100755 --- a/src/ios/OverAppBrowser.m +++ b/src/ios/OverAppBrowser.m @@ -7,7 +7,7 @@ // #import "OverAppBrowser.h" -#import +//#import @implementation OverAppBrowser @@ -16,8 +16,8 @@ @implementation OverAppBrowser -(CDVPlugin*) initWithWebView:(UIWebView*)theWebView { - self = (OverAppBrowser*)[super initWithWebView:theWebView]; - + //self = (OverAppBrowser*)[super initWithWebView:theWebView]; + [self pluginInitialize]; if (self != nil) { _callbackIdPattern = nil; } @@ -256,8 +256,25 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper { if (!_injectedIframeBridge) { _injectedIframeBridge = YES; + + //[[super webView] stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"javascript:window.plugins.appsFlyer.onInstallConversionDataLoaded(%@)", JSONString]]; + //[[super webViewEngine] evaluateJavaScript:[NSString stringWithFormat:@"javascript:window.plugins.appsFlyer.onInstallConversionDataLoaded(%@)", JSONString] completionHandler:nil]; + + + + // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController - [self.overWebView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; + //[self.overWebView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; + + NSString* jsString = [NSString stringWithString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; + + if ([self.overWebView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + // Cordova-iOS pre-4 + [self.overWebView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsString waitUntilDone:NO]; + } else { + // Cordova-iOS 4+ + [self.overWebView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:jsString waitUntilDone:NO]; + } } if (jsWrapper != nil) { @@ -266,10 +283,24 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper if (sourceArrayString) { NSString* sourceString = [sourceArrayString substringWithRange:NSMakeRange(1, [sourceArrayString length] - 2)]; NSString* jsToInject = [NSString stringWithFormat:jsWrapper, sourceString]; - [self.overWebView stringByEvaluatingJavaScriptFromString:jsToInject]; + //[self.overWebView stringByEvaluatingJavaScriptFromString:jsToInject]; + if ([self.overWebView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + // Cordova-iOS pre-4 + [self.overWebView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:jsToInject waitUntilDone:NO]; + } else { + // Cordova-iOS 4+ + [self.overWebView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:jsToInject waitUntilDone:NO]; + } } } else { - [self.overWebView stringByEvaluatingJavaScriptFromString:source]; + //[self.overWebView stringByEvaluatingJavaScriptFromString:source]; + if ([self.overWebView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) { + // Cordova-iOS pre-4 + [self.overWebView performSelectorOnMainThread:@selector(stringByEvaluatingJavaScriptFromString:) withObject:source waitUntilDone:NO]; + } else { + // Cordova-iOS 4+ + [self.overWebView performSelectorOnMainThread:@selector(evaluateJavaScript:completionHandler:) withObject:source waitUntilDone:NO]; + } } } @@ -346,6 +377,4 @@ - (void) browserExit self.currentUrl = nil; } - - -@end +@end \ No newline at end of file