@@ -57,9 +57,8 @@ @implementation FIRDLJavaScriptExecutor {
57
57
__weak id <FIRDLJavaScriptExecutorDelegate> _delegate;
58
58
NSString *_script;
59
59
60
- // Web views with which to run JavaScript.
61
- UIWebView *_uiWebView; // Used in iOS 7 only.
62
- WKWebView *_wkWebView; // Used in iOS 8+ only.
60
+ // Web view with which to run JavaScript.
61
+ WKWebView *_wkWebView;
63
62
}
64
63
65
64
- (instancetype )initWithDelegate : (id <FIRDLJavaScriptExecutorDelegate>)delegate
@@ -82,17 +81,9 @@ - (void)start {
82
81
NSString *htmlContent =
83
82
[NSString stringWithFormat: @" <html><head><script>%@ </script></head></html>" , _script];
84
83
85
- // Use WKWebView if available as it executes JavaScript more quickly, otherwise, fall back
86
- // on UIWebView.
87
- if ([WKWebView class ]) {
88
- _wkWebView = [[WKWebView alloc ] init ];
89
- _wkWebView.navigationDelegate = self;
90
- [_wkWebView loadHTMLString: htmlContent baseURL: nil ];
91
- } else {
92
- _uiWebView = [[UIWebView alloc ] init ];
93
- _uiWebView.delegate = self;
94
- [_uiWebView loadHTMLString: htmlContent baseURL: nil ];
95
- }
84
+ _wkWebView = [[WKWebView alloc ] init ];
85
+ _wkWebView.navigationDelegate = self;
86
+ [_wkWebView loadHTMLString: htmlContent baseURL: nil ];
96
87
}
97
88
98
89
- (void )handleExecutionResult : (NSString *)result {
@@ -109,8 +100,6 @@ - (void)handleExecutionError:(nullable NSError *)error {
109
100
}
110
101
111
102
- (void )cleanup {
112
- _uiWebView.delegate = nil ;
113
- _uiWebView = nil ;
114
103
_wkWebView.navigationDelegate = nil ;
115
104
_wkWebView = nil ;
116
105
}
@@ -150,33 +139,6 @@ - (void)webView:(WKWebView *)webView
150
139
[self handleExecutionError: error];
151
140
}
152
141
153
- #pragma mark - UIWebViewDelegate
154
-
155
- - (void )webViewDidFinishLoad : (UIWebView *)webView {
156
- // Make sure that the javascript was loaded successfully before calling the method.
157
- NSString *methodType =
158
- [webView stringByEvaluatingJavaScriptFromString: FIRDLTypeofFingerprintJSMethodNameString ()];
159
- if (![methodType isEqualToString: @" function" ]) {
160
- // Javascript was not loaded successfully.
161
- [self handleExecutionError: nil ];
162
- return ;
163
- }
164
-
165
- // Get the result from javascript.
166
- NSString *result =
167
- [webView stringByEvaluatingJavaScriptFromString: GINFingerprintJSMethodString ()];
168
- if ([result isKindOfClass: [NSString class ]]) {
169
- [self handleExecutionResult: result];
170
- } else {
171
- [self handleExecutionError: nil ];
172
- }
173
- }
174
-
175
- - (void )webView : (UIWebView *)webView
176
- didFailLoadWithError : (FIRDL_NULLABLE_IOS9_NONNULLABLE_IOS10 NSError *)error {
177
- [self handleExecutionError: error];
178
- }
179
-
180
142
@end
181
143
182
144
NS_ASSUME_NONNULL_END
0 commit comments