Skip to content

Commit

Permalink
removed CDVJSON and fixes for latest cordova
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Roth committed Sep 5, 2017
1 parent 6861d4b commit baa2172
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions src/ios/OverAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "OverAppBrowser.h"
#import <Cordova/CDVJSON.h>
//#import <Cordova/CDVJSON.h>

@implementation OverAppBrowser

Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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];
}
}
}

Expand Down Expand Up @@ -346,6 +377,4 @@ - (void) browserExit
self.currentUrl = nil;
}



@end
@end

0 comments on commit baa2172

Please sign in to comment.