authenticate, deposit, withdraw and callSmartContract verify that they are being executed in a React Native WebView environment before trying before trying to communicate with the Lemon Cash App, and they return an error message if no React Native WebView is detected.
Usage
Parameters
This function takes no parameters.Returns
Returns
true if the application is running inside a React Native WebView environment, false otherwise.Detection Methods
The function uses multiple detection strategies to ensure accurate React Native WebView identification:1. ReactNativeWebView Object
Checks ifwindow.ReactNativeWebView is available, which is the primary indicator of a React Native WebView environment.
2. User Agent String
Looks for'ReactNativeWebView' in the browser’s user agent string.
3. CSS Class Detection
Checks if the document root element has the'ReactNativeWebView' CSS class.
4. SSR Safety
Returnsfalse when window is undefined (server-side rendering scenarios).
Complete Example
UX Tips
- Feature Gating: Use this function to conditionally enable/disable features based on the environment.
- User Experience: Provide clear feedback when features are not available in the current environment.
- Fallback Handling: Implement graceful fallbacks for non-WebView environments.