4

I am the developer of Boxy, a famous native wrapper around Inbox by Gmail, and wanted to ask if anyone is able to help with something I have been struggling with since day one of development.

Here is the problem: links on inbox.google.com and gmail.com work differently than on other sites: clicking on them does not trigger a navigation action on my webview (I am using a WKWebView specifically, but the problem is also present using the old WebView). So I am having a difficult time opening links in an external browser when appropriate.

Because of this, at the time of this writing, I am relying on a terrible hack in order to open links: intercepting clicks on the document.body with javascript (using an event listener) and then forcing them to open on the external browser by calling the native app.

My best guess is that the Gmail/Inbox apps perform some javascript magic in order to track clicks on all the links inside emails and that, somehow, this interfers with the standard behaviour.

Has anyone got any idea how I can solve this problem?

Things I already tried

  • Implementing the method -webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures: of WKUIDelegate. Did not work: the method is called but the request associated with the navigation action is empty.
Francesco
  • 1,047
  • 11
  • 26

1 Answers1

0

I found a solution. This issue is due to when clicking link, instead of opening using target=_blank, Gmail attempts to open an about:blank window and then run javascript to redirect the link. You need to make sure that Gmail can correctly receive the handle of the created window.

- (WKWebView *)webView:(WebUI *)webView
createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration
forNavigationAction:(WKNavigationAction *)navigationAction
windowFeatures:(WKWindowFeatures *)windowFeatures

You need to make sure this delegate method correctly returns the newly created wkwebview.

Larry
  • 858
  • 10
  • 16
  • you seem to be right... but returning my new webview from this callback doesn't seem to work, as if the returned wkwebview was not matching the criteria Google will use to find it. Did you identify exactly how Google looks for the new tab? – Jérôme Beau Jul 26 '21 at 15:58