capacitor-inappbrowser icon indicating copy to clipboard operation
capacitor-inappbrowser copied to clipboard

Question: no preventDeeplink for openWebView ?

Open KkatieJ opened this issue 1 year ago • 10 comments

Pardon a noob, but i've had some issues with my code and the plugin past versions 1.2.19 I think, but not sure we had this specific issue. My app is using capacitor, this summer we updated to capacitor 6 and also lifted SDK target version to 34, so we were forced to also update this plugin, while I face similar issue on iOS I'll focus on android for now, and try my best to explain it, I need to open an external app, do a specific action after which my app listens for url changes and if it encounters an url containing a specific keyword it modifies the return url to point back to my app, but what I am encountering now is that it seems to pause my app (or stop listening for url changes) before the url has changed to the url that contains the required keyword, thus the process that I am trying to do just fails and I'm navigated to chrome because it tries to open the url that was caught last insead of the one that should point back to my app. It succesfully catches the first three url changes but pauses right before the fourth one that would trigger the if block that modifies return URL to point back to our application. logcat specifically shows that App paused which previously did not happen? Has anyone encountered a similar issue? Maybe someone has any ideas what has changed?

KkatieJ avatar Dec 03 '24 15:12 KkatieJ

So, I finally managed to look into it a bit more, the method I am using is openWebView() and this is the code that is the issue, since there is no preventDeeplink option for openWebView, this is what's breaking my app, which I see was brought in with this change: https://github.com/Cap-go/capacitor-inappbrowser/commit/4b820e1ebec241fc82870bbae37366f27f200d00

image

KkatieJ avatar Jan 05 '25 10:01 KkatieJ

Still need to test stuff for iOS, since I am facing the same issue on that platform as well

KkatieJ avatar Jan 05 '25 11:01 KkatieJ

it seems to fail when trying to open a custom schema I use, first step works because I use URLs that start with https, but when it seems to reach my custom schema it no longer recognizes it.

KkatieJ avatar Jan 09 '25 12:01 KkatieJ

Issue is related to #261 - see infos there. Any news here? I tried with capgo v. 6.9.18 and 6.9.33 but iOS deeplinks do not seem to work.

MarcelSchuermann avatar Jan 18 '25 14:01 MarcelSchuermann

I see that migration to Capacitor v7 has already been done before this has been fixed :(

KkatieJ avatar Jan 27 '25 09:01 KkatieJ

Did migration to Cap 7 fix that issue for you? @KkatieJ

Sad, I think about any other good workaround to communicate with the app without deep links.

A possible workaround might be to use postMessage(...) function. But I was not lucky with it yet.

Then listening to the message from within the app: addListener("messageFromWebview", listenerFunc: (event: Record <string, any>) => void)

MarcelSchuermann avatar Jan 28 '25 20:01 MarcelSchuermann

@MarcelSchuermann I haven't tried yet as I don't think it's related to Capacitor, however, what somewhat helped for my case with iOS was changing the let preventDeeplink = call.getBool("preventDeeplink", false) in InAppBrowserPlugin.swift to true directly in the openWebView() function, should be in line 181, but I have to add that somehow this fix worked only after updating Xcode version to latest, as I was previously using 15.x and had to update to 16.x for this to work as I need, which in return caused some other build issues related to firestore (updating xcode that is)

KkatieJ avatar Jan 28 '25 20:01 KkatieJ

Hi @KkatieJ

Thanks a lot for your input.

I was lucky and could make it work using the postMessage(...) workaround. window.mobileApp.postMessage({ "detail": { "message": "myMessage" } })

Hope it helps, wish you good luck! :)

MarcelSchuermann avatar Jan 29 '25 20:01 MarcelSchuermann

Can you make a reproduction from that i will be able to help you

riderx avatar Feb 01 '25 02:02 riderx

Please try 7.6.8 of @6.14.0 I fixed deep link iOS + prevent deep links in both platform and made this website to test and explain how to config deep links: https://aasa-tester.capgo.app/

riderx avatar Mar 26 '25 00:03 riderx