adjust / ios_sdk

This is the iOS SDK of
http://www.adjust.com
MIT License
623 stars 294 forks source link

4.38.4 does not forward decidePolicyFor navigationAction: WKNavigationAction #719

Closed RalfK92 closed 4 months ago

RalfK92 commented 5 months ago

I've upgraded from 4.38.2 to 4.38.4 and since then some WKNavigationDelegete functions are no longer forwarded into my WebViewController. After removing self.adjustBridge.loadWKWebViewBridge(self.webView, wkWebViewDelegate: self) from my code the method is received again.

Aditi3 commented 5 months ago

Hi @RalfK92,

Can you verify that navigationDelegate is assigned to self in your WebViewController class? Also, please make sure to add this after initializing the AdjustBridge.

I've tested with the below code snippet, and it works with version 4.38.4 and later.

AdjustBridge *adjustBridge = [[AdjustBridge alloc] init];
[adjustBridge loadWKWebViewBridge:self.webView wkWebViewDelegate:self];
self.webView.navigationDelegate = self;

I hope this helps.

RalfK92 commented 5 months ago

Yes i'm sure that the delegate is assigned, cause i'm receiving the delegate function after commenting out the loadWKWebViewBridge func. But its done in a inherited class not after the load of the bridge.

Wouldn't overriding the delegate after initializing the bridge prevent adjust from receiving the functions and therefore no tracking data would be gathered.

Furthermore i still receive the func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)

func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse) async -> WKNavigationResponsePolicy But not the webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) which works in 4.38.2.

Aditi3 commented 5 months ago

Thank you for sharing the details.

Could you check if the delegate webView:decidePolicyForNavigationAction:preferences:decisionHandler: is getting called in your current setup?

RalfK92 commented 5 months ago

Yes the delegate function webView:decidePolicyForNavigationAction:preferences:decisionHandler: gets called.

Aditi3 commented 4 months ago

In version 4.38.3, our SDK added support for webView:decidePolicyForNavigationAction:preferences:decisionHandler: To receive a callback, you need to add it to your codebase.

As per Apple documentation, either the webView:decidePolicyForNavigationAction:preferences:decisionHandler: or webView:decidePolicyForNavigationAction:decisionHandler: delegate method is called. I recommend having both if your application supports iOS versions below 13.0.

Apologies for the inconvenience caused.

RalfK92 commented 4 months ago

@Aditi3 Thanks for the clarification. I will close the issue.

Would be nice to write that down in your documentation as well.