Skip to content

Commit

Permalink
refactor: drop uiwebview & add wkwebview (#773)
Browse files Browse the repository at this point in the history
* refactor: drop uiwebview & default to wkwebview
* refactor: remove CDVLocalStorage
* refactor: set CDVWebViewNavigationTypeOther as -1
* refactor: udpated & fixed cordova.js
* refactor: force WK_WEB_VIEW_ONLY flag to true

Note:
* The WK_WEB_VIEW_ONLY flag is hardcoded to true. This is to ensure that the IAB@3.2.x plugin is forced to use WKWebView as this release does not support UIWebView.
* The WK_WEB_VIEW_ONLY flag is kept only as part of a transitioning period. The flag will be removed in a later release.
  • Loading branch information
erisu authored Feb 10, 2020
1 parent 266d339 commit 240a177
Show file tree
Hide file tree
Showing 40 changed files with 1,324 additions and 2,262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVWhitelist.h>

#if WK_WEB_VIEW_ONLY
#define CDVWebViewNavigationType int
#else
#define CDVWebViewNavigationType UIWebViewNavigationType
#endif

typedef NS_ENUM(NSInteger, CDVIntentAndNavigationFilterValue) {
CDVIntentAndNavigationFilterValueIntentAllowed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,15 @@ - (CDVIntentAndNavigationFilterValue) filterUrl:(NSURL*)url
return [[self class] filterUrl:url intentsWhitelist:self.allowIntentsWhitelist navigationsWhitelist:self.allowNavigationsWhitelist];
}

#if WK_WEB_VIEW_ONLY
#define CDVWebViewNavigationTypeLinkClicked 0
#define CDVWebViewNavigationTypeOther 5
#else
#define CDVWebViewNavigationTypeLinkClicked UIWebViewNavigationTypeLinkClicked
#define CDVWebViewNavigationTypeOther UIWebViewNavigationTypeOther
#endif
#define CDVWebViewNavigationTypeLinkOther -1

+ (BOOL)shouldOpenURLRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType
{
return (CDVWebViewNavigationTypeLinkClicked == navigationType ||
(CDVWebViewNavigationTypeOther == navigationType &&
[[request.mainDocumentURL absoluteString] isEqualToString:[request.URL absoluteString]]
)
);
return (
navigationType == CDVWebViewNavigationTypeLinkClicked ||
navigationType == CDVWebViewNavigationTypeLinkOther
);
}

+ (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(CDVWebViewNavigationType)navigationType filterValue:(CDVIntentAndNavigationFilterValue)filterValue
Expand All @@ -123,8 +117,7 @@ + (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(CDV
case CDVIntentAndNavigationFilterValueNavigationAllowed:
return YES;
case CDVIntentAndNavigationFilterValueIntentAllowed:
// only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) OR
// it's a UIWebViewNavigationTypeOther, and it's an internal link
// only allow-intent if it's a CDVWebViewNavigationTypeLinkClicked (anchor tag) or CDVWebViewNavigationTypeOther and it's an internal link
if ([[self class] shouldOpenURLRequest:request navigationType:navigationType]){
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
Expand Down

This file was deleted.

Loading

0 comments on commit 240a177

Please sign in to comment.