0

I want to open website in React-Native app with below requirements:

  1. Open website from app
  2. Select appropriate record from list
  3. Click on Edit button
  4. Edit appropriate details
  5. Click on Save button

Above is requirement to provide user better experience from app rather than going to website and do multiple clicks. How to achieve above in React-Native?

PS: We used to use WebBrowserControl in desktop windows app for above requirement and want to replicate same in React-Native android app.

Ramesh
  • 13
  • 7
  • Hello, welcome to stackoverflow, please read https://stackoverflow.com/help/on-topic and https://stackoverflow.com/help/how-to-ask – Martin54 Dec 04 '19 at 07:52

1 Answers1

0

You have to do the same things what you have done in the web part. Just you have to inject the JavaScript code to a webview. Webview will help you to open the website and then you have to inject the JavaScript code based on certain conditions and you can achieve the same as web. More you can read here :-

abhikumar22
  • 1,764
  • 2
  • 11
  • 24
  • Thanks for your reply. The requirement I mentioned is just 1% of total processing. Actual process is quite complex and lengthy wherein I need to open website, login with user credentials, search for records, select multiple records, perform operation on 1 record at a time, validate rules and finally submit data. Is there any better way like document.getElementById('txtusername'.).value = 'user', document.getElementById('txtpassword'.).value = 'password' and document.getElementById('submitbutton').click()? – Ramesh Dec 04 '19 at 07:09
  • the code which you have done in web part will help you here,,,,that's what i have told...You need to perform these actions after opening the webview in react native and then inject the JavaScript code to the webview based on conditions. It is possible to do in react native – abhikumar22 Dec 04 '19 at 07:12
  • I tried sample code from https://facebook.github.io/react-native/docs/webview.html in online editor like codesandbox.io and snack.expo.io. However, both shows blank preview for both URL and static HTML in WebView. Do you have any idea about what am I missing? – Ramesh Dec 04 '19 at 08:53
  • use webview as child and make a view parent with style equal to flex:1....you are missing there – abhikumar22 Dec 04 '19 at 09:38
  • @Ramesh accept the answer if it works for you thanks :) – abhikumar22 Dec 04 '19 at 09:40
  • I changed code as suggested. Still, no luck. See https://snack.expo.io/r1VWQ-rTS – Ramesh Dec 04 '19 at 09:59
  • try to open it in emulator,,,,,,,it will work .....in snack it is not showing – abhikumar22 Dec 04 '19 at 10:14
  • I am unable to keep track of current page displayed in WebView. Please refer to https://snack.expo.io/rynWevUTB. I am trying to store current page in currentStep variable. However, it is 'login' all the time as it is initialised at top. Any way to store current page shown in WebView and inject javascript based on current page? This is to achieve very long and complex set of actions which otherwise user has to do manually. – Ramesh Dec 05 '19 at 10:51