1

From reading and trial of the React Native Linking API - Linking.openURL(url) works well for GET requests.

But how does one use Linking with a http/s POST?

In short, my App knows all the form fields required for a POST, so I want to bypass the bad UX of opening to a blank web <FORM> simply to have the user laboriously input data into it...

Have I missed something in the Linking API? or is to work to be done?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
pkbyron
  • 163
  • 3
  • 9

1 Answers1

2

Linking api nor the internal native api support POST request for opening urls. If you have control of web form as well. Maybe you can send post request as query (GET) parameters in opneUrl call and populate form from query. If you are sending any sensitive information then this is not recommended.

Second approach can be using webView to show your web form instead of opening url throguh Linking api.

For making post request, first you can generate a html string for webview which will submit a post request to your actual form using javascript. Open Url hosted using POST method in Safari using sharedApplication openURL method

Community
  • 1
  • 1
while1
  • 3,320
  • 19
  • 12
  • Thanks for the quick response (while1). There is some sensitive data involved (SESSION_KEY), which would be ok if encapsulated in an encrypted POST payload, so can't put that type of data onto GET query string. As a work around we decided to do a two step process: 1. POST data to API - which responds with a unique result token. 2. Then with GET use token to call the endpoint where the results are stored temporarily. Hopefully POST will be added to Linking soon. cheers – pkbyron Sep 05 '16 at 09:02