New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cordova-plugin-native-fallback

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-native-fallback

A Cordova plugin that provides a native fallback for network errors.

latest
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

Cordova Native Fallback Plugin

A Cordova plugin that provides a native UI fallback when your application fails to load its web content due to a network error.

This plugin automatically detects when the Cordova WebView cannot reach a remote URL and displays a native alert dialog, prompting the user to retry the connection. This prevents users from seeing a blank or broken page and provides a much cleaner user experience.

Supported Platforms

  • Android
  • iOS

Installation

You can add this plugin to your Cordova project from NPM (once published) or directly from a Git repository.

# Install from NPM (replace with your actual plugin name if different)
cordova plugin add cordova-plugin-native-fallback

# Or, install directly from a Git repository
cordova plugin add <your-git-repository-url>

How It Works

The plugin works automatically out of the box. Once installed, it hooks into the native WebView's lifecycle on both Android and iOS.

  • It listens for page loading errors, such as when the device is offline or a server is unreachable.
  • When an error is detected, it suppresses the default web error page (e.g., "Webpage not available").
  • Instead, it displays a native alert dialog with a "Network Error" message and a "Retry" button.
  • If the user taps "Retry", the plugin attempts to reload the original URL that your app was trying to access.

Usage

This plugin is designed to be zero-configuration. Simply install it, and it will handle network errors automatically.

Manual Trigger (Optional)

For advanced scenarios where your application has its own logic for detecting content loading failures, you can manually trigger the native error dialog from your JavaScript code.

cordova.plugins.nativeFallback.triggerErrorFallback(
  function() { console.log("Fallback success"); },
  function() { console.log("Fallback error"); }
);

Configuration

To ensure the plugin works correctly, you may need to configure the retry URL. By default, it points to a placeholder.

To customize this, you will need to edit the source files directly:

  • Android: src/android/NativeFallback.java
  • iOS: src/ios/NativeFallback.m

In both files, find the line containing https://your.remote.url and replace it with your application's primary entry point URL.

Keywords

cordova

FAQs

Package last updated on 30 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts