Adding Headers to WebBrowser.openBrowserAsync?

Please provide the following:

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS/web/all): Android/iOS

Hi

I want to open a link to a specific page with the WebBrowser.openBrowserAsync() function from the 'expo-web-browser' package.

Is there a way to add a header to this request, or any alternative way that I can add a header to URL? Perhaps even using cURL instead of just a link + body + headers.

Any pointers in the right direction will be helpful, thanks.

I kind of doubt this is possible. WebBrowser.openBrowserAsync() on iOS is essentially an interface for SFSafariViewController, which just initializes with a URL. This API is basically just asking the OS to open a URL in the OS web browser.

Ahw. That sucks. Thanks for the reply.

Do you perhaps have any/know of any alternatives that I can use within expo?

Would WebView not work for you, or sending the user to a URL that basically redirects him with the headers?

what are you trying to accomplish? I don’t understand why its necessary to change the request headers. The OS browser doesn’t normally let you do this.

I have been looking in to WebView now, thanks! It seems a bit better, and I’m sort of getting right what I want to do.

I’m using an external third party payment platform. The user clicks on a button from inside the app that redirects them to our website and from the website it redirects them to the payment platform - but for the user they only see that they go straight to the payment platform.
For the backend to know which user it is that is currently clicking, I need to send their JWT and a userID in the header to the backend during the initial URL request, so that the backend can link the payment that’s being made with the correct user.

App → Backend (requires userID and JWT in the header) → Authenticated Payment platform.

For user-friendly reasons, I want the payment to be done from inside the app - so I want to display all of this in a modal browser or something similar.

I could see using an embedded webview for this, particularly since you wouldn’t want the session to live any longer than needed to complete the payment (and that will let you set the header). I think WebBrower could be practical if you could exchange the JWT/ user ID for a one-time use token for the payment system that would be included in the URL (it would definitely have to only be good for one use, though).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.