@@ -57,9 +57,8 @@ @implementation FIRDLJavaScriptExecutor {
5757 __weak id <FIRDLJavaScriptExecutorDelegate> _delegate;
5858 NSString *_script;
5959
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;
6362}
6463
6564- (instancetype )initWithDelegate : (id <FIRDLJavaScriptExecutorDelegate>)delegate
@@ -82,17 +81,9 @@ - (void)start {
8281 NSString *htmlContent =
8382 [NSString stringWithFormat: @" <html><head><script>%@ </script></head></html>" , _script];
8483
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 ];
9687}
9788
9889- (void )handleExecutionResult : (NSString *)result {
@@ -109,8 +100,6 @@ - (void)handleExecutionError:(nullable NSError *)error {
109100}
110101
111102- (void )cleanup {
112- _uiWebView.delegate = nil ;
113- _uiWebView = nil ;
114103 _wkWebView.navigationDelegate = nil ;
115104 _wkWebView = nil ;
116105}
@@ -150,33 +139,6 @@ - (void)webView:(WKWebView *)webView
150139 [self handleExecutionError: error];
151140}
152141
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-
180142@end
181143
182144NS_ASSUME_NONNULL_END
0 commit comments