urbanairship / ios-library

Urban Airship iOS SDK
http://urbanairship.com
Apache License 2.0
478 stars 265 forks source link

Some iOS 16.4+ users are not getting WKNavigationDelegate `decidePolicyFor` callback in NativeBridge.swift #363

Closed mrmonopoly237 closed 1 year ago

mrmonopoly237 commented 1 year ago

Preliminary Info

What Airship dependencies are you using?

AirshipCore, AirshipMessageCenter, AirshipAutomation

What are the versions of any relevant development tools you are using?

Xcode 14.3, including Airship frameworks via Swift Package Manager

Report

What unexpected behavior are you seeing?

Buttons in Inbox messages are not triggering the javascript event to execute the expected action for certain users running iOS 16.4+.

What is the expected behavior?

When users press the button, they should be taken to the embedded URL

What are the steps to reproduce the unexpected behavior?

Send a test inbox message to an affected device, and tap on a button to execute a link.

Do you have logging for the issue?

No logging, but this behavior was extremely similar to something we saw impacting a WKWebView elsewhere in our app: affected devices were not getting a WKNavigationDelegate decidePolicyFor callback.

The root cause appears to be that within the AirshipCore framework, the NativeBridge.swift does not leverage the iOS 13+ WKNavigationDelegate function: webView(_:decidePolicyFor:preferences:decisionHandler:)

If I modify the code locally to include this delegate callback, the issue is resolved for affected devices.

I am guessing this is a bug on Apple's end, as the iOS 8+ decidePolicyFor delegate callback has no deprecation warnings, or indication that it would stop working.

rlepinski commented 1 year ago

Thanks for the report. If you read the docs it has this hint:

If your delegate object implements this method, the web view doesn’t call the [webView(_:decidePolicyFor:decisionHandler:)](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview) method.

Are you implementing that method in your app? If not, it might be another SDK swizzling that method in. Either way we can see if we can implement that method instead of the current one.

mrmonopoly237 commented 1 year ago

We are implementing that in another web view, but it is not tied to the web view used for the inbox. The web view inbox WKNavigationDelegate was only using the iOS 8+ function.

mrmonopoly237 commented 1 year ago

So... egg on my face. It was a third party swizzling the method. They have released an update back on the 31st of May addressing the problem. We had not updated to the most recent version.

rlepinski commented 1 year ago

Awesome. It was proving a bit difficult to move to this method since we support iOS 11+ right now. We will switch to the updated method in SDK 17 which will have iOS 14+ as a min version