'React native webview copy and download not working

I have built an android app using react native. Inside the app I am using the react-native-webview package to show a React app.

import {WebView} from 'react-native-webview';

<WebView
  useWebKit={true}
  source={{
    uri: 'https://myappurl.com',
  }}
  style={{flex: 1}}
/>

I have set the android.permission.WRITE_EXTERNAL_STORAGE permission in andoid manifest and also set android.useAndroidX=true and android.enableJetifier=true in gradle properties. Yet when I copy something in the react app or download a file, it doesn't happend at the device level. If I run the react app independently in a web browser I am able to copy and download.

According to the documentation of react-native-webview nothing else needs to be done and this functionality should be inbuilt. What could be the issue?



Solution 1:[1]

Found the issue. For copy i was using the navigator.clipboard api and for download i was using a blob object. The web view only supports the document.execCommand() api for copy, and for download it only supports download through the Content-Disposition: attachment; header.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 chetan