[SOLVED] Linking.openURL [Possible Unhandled Promise Rejection]
See original GitHub issueBug description: My website has a WhatsApp floating button and when clicking it, I was able to open the WhatsApp native application from that button, but I’m getting a warning in the metro console.
Trying to open Linking.openURL(url) from onNavigationStateChange WebView prop, I get warning Possible Unhandled Promise Rejection
The URL I’m trying to open is whatsapp://send?phone=XXXXXXXXX
<WebView
ref={(ref) => (this.webview = ref)}
originWhitelist={['https://', 'whatsapp://']}
source={{ uri: 'https://xxx.xxxx.xxx/' }}
onNavigationStateChange={this.handleWebViewNavigationStateChange}
onMessage={(event: WebViewMessageEvent) => {
alert(event.nativeEvent.data);
}}
/>
handleWebViewNavigationStateChange = (newNavState: WebViewNavigation) => {
console.log('nav state changed');
if (url.startsWith('whatsapp://')) {
this.webview.stopLoading();
Linking.openURL(url);
}
};
Environment:
- OS: Linux Mint 20.3
- react-native version: 0.64.3
- react-native-webview version: 11.15.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
React Native: Linking.openUrl throwing "Possible Unhandled ...
I am trying to create a Audio/Video Calling app using React Native. There's a screen in the app where calling happens using WebRTC....
Read more >Fixing the React Native Error: "Unable to open URL: telprompt"
If the user cancels the call, the Promise is rejected. This triggers the error you see in the screenshot. As you can see,...
Read more >unhandled promise about:blank in IOS-React Native
How to save Firestore response, after I add a doc, in React Native (Possible Unhandled Promise Rejection (id: 1): TypeError: "res" is read-only)?...
Read more >React Native Auth0 Possible Unhandled Promise Rejection
In setting up samples, I've made some progress with the docs, but I've come into this error. Possible Unhandled Promise Rejection (id: 1): ......
Read more >Linking - React Native
You can handle these events with Linking.getInitialURL() - it returns a Promise that resolves to the URL, if there is one. Example. Open...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
However you like dealing with promises. You could use
async
/await
and wrap it in atry
/catch
, or use.then
/.catch
.I’m personally a fan of using
no-floating-promises
to help avoid these types of issues.Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically