Skip to main content
Use this function to enable or disable features related to Lemon Mini Apps. For safety, all methods: authenticate, deposit, withdraw and callSmartContract verify that they are being executed in a React Native WebView environment before trying to communicate with the Lemon App, and they return an error message if no React Native WebView is detected.

Usage

Parameters

This function takes no parameters.

Returns

Promise<boolean>
Promise<boolean>
Returns a Promise that resolves to true if the application is running inside Lemon’s WebView environment, false otherwise.

How It Works

The function uses a communication-based approach to verify the environment:
  1. First checks if the app is in a React Native WebView.
  2. If it is, it sends a message to the native Lemon app requesting confirmation.
  3. Waits for a response with a 1-second timeout.
  4. Returns true only if the native app confirms, false otherwise.

Complete Example

Migration from old isWebView

isWebView has been replaced by isLemonWebView. The old isWebView function is deprecated and will become a private function in a future release. Please migrate to isLemonWebView.
If you are currently using isWebView, update your code as follows:
Key differences:
  • isLemonWebView is async and returns a Promise<boolean>, while isWebView was synchronous.
  • isLemonWebView confirms the host app is the Lemon App, not just any React Native WebView.

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-Lemon’s App environments.