Skip to content

Commit

Permalink
Remove references to UIWebView from DynamicLinks to comply with Apple…
Browse files Browse the repository at this point in the history
… "ITMS-90809: Deprecated API Usage" (#3723)
  • Loading branch information
dloic authored and paulb777 committed Aug 29, 2019
1 parent 1e889cf commit 7095c0b
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions Firebase/DynamicLinks/FIRDLJavaScriptExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ @implementation FIRDLJavaScriptExecutor {
__weak id<FIRDLJavaScriptExecutorDelegate> _delegate;
NSString *_script;

// Web views with which to run JavaScript.
UIWebView *_uiWebView; // Used in iOS 7 only.
WKWebView *_wkWebView; // Used in iOS 8+ only.
// Web view with which to run JavaScript.
WKWebView *_wkWebView;
}

- (instancetype)initWithDelegate:(id<FIRDLJavaScriptExecutorDelegate>)delegate
Expand All @@ -82,17 +81,9 @@ - (void)start {
NSString *htmlContent =
[NSString stringWithFormat:@"<html><head><script>%@</script></head></html>", _script];

// Use WKWebView if available as it executes JavaScript more quickly, otherwise, fall back
// on UIWebView.
if ([WKWebView class]) {
_wkWebView = [[WKWebView alloc] init];
_wkWebView.navigationDelegate = self;
[_wkWebView loadHTMLString:htmlContent baseURL:nil];
} else {
_uiWebView = [[UIWebView alloc] init];
_uiWebView.delegate = self;
[_uiWebView loadHTMLString:htmlContent baseURL:nil];
}
_wkWebView = [[WKWebView alloc] init];
_wkWebView.navigationDelegate = self;
[_wkWebView loadHTMLString:htmlContent baseURL:nil];
}

- (void)handleExecutionResult:(NSString *)result {
Expand All @@ -109,8 +100,6 @@ - (void)handleExecutionError:(nullable NSError *)error {
}

- (void)cleanup {
_uiWebView.delegate = nil;
_uiWebView = nil;
_wkWebView.navigationDelegate = nil;
_wkWebView = nil;
}
Expand Down Expand Up @@ -150,33 +139,6 @@ - (void)webView:(WKWebView *)webView
[self handleExecutionError:error];
}

#pragma mark - UIWebViewDelegate

- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Make sure that the javascript was loaded successfully before calling the method.
NSString *methodType =
[webView stringByEvaluatingJavaScriptFromString:FIRDLTypeofFingerprintJSMethodNameString()];
if (![methodType isEqualToString:@"function"]) {
// Javascript was not loaded successfully.
[self handleExecutionError:nil];
return;
}

// Get the result from javascript.
NSString *result =
[webView stringByEvaluatingJavaScriptFromString:GINFingerprintJSMethodString()];
if ([result isKindOfClass:[NSString class]]) {
[self handleExecutionResult:result];
} else {
[self handleExecutionError:nil];
}
}

- (void)webView:(UIWebView *)webView
didFailLoadWithError:(FIRDL_NULLABLE_IOS9_NONNULLABLE_IOS10 NSError *)error {
[self handleExecutionError:error];
}

@end

NS_ASSUME_NONNULL_END

0 comments on commit 7095c0b

Please sign in to comment.