I’m developing a React Native application that includes links to various websites, allowing users to click and navigate to specific pages. However, I’m encountering problems with Google Docs links on Android (iOS testing is pending). When users click any of these links, an error appears. If they attempt to open the link through the Docs app, the error states, “Document lookup failed. The document may have been removed,” while opening it in Chrome results in the message, “Sorry, the requested file does not exist.” Interestingly, if the link URL is copied and pasted directly into the Chrome search bar, the document appears correctly.
Here’s how the linking is implemented:
import { Linking } from 'react-native';
const handleLinkPress = async () => {
let refinedLink = link.toLowerCase();
if (!/^https?:\/\//.test(refinedLink) && !/^mailto:/.test(refinedLink)) {
refinedLink = `https://${refinedLink}`;
}
Linking.openURL(refinedLink);
};
The Android Manifest.xml file contains:
<manifest ...>
...
<uses-permission android:name="android.permission.INTERNET" />
...
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http"/>
</intent>
</queries>
</manifest>
Version details:
react-native: 0.66.5 (I realize an upgrade is necessary, but I’m uncertain if it will resolve this problem)
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
I have verified that the link the application attempts to open is accurate. I looked into the React Native Linking documentation as well as the Android documentation, but it appears that the Android documentation primarily emphasizes incoming deep links rather than outgoing links.