Skip to content

Commit

Permalink
Merge pull request etabard#9 from theroth/master
Browse files Browse the repository at this point in the history
Added support for cordova [email protected]. Removed CDVJSON and fixes for latest cordova
  • Loading branch information
etabard authored Jan 12, 2018
2 parents 6861d4b + 8d62679 commit 4397909
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 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 @@ -78,7 +78,7 @@ - (void) open:(CDVInvokedUrlCommand *)command
self.overWebView.contentMode = UIViewContentModeScaleToFill;
self.overWebView.multipleTouchEnabled = YES;
self.overWebView.opaque = NO;
self.overWebView.scalesPageToFit = NO;
self.overWebView.scalesPageToFit = YES;
self.overWebView.userInteractionEnabled = YES;

self.overWebView.alpha = 0;
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 4397909

Please sign in to comment.