Skip to content

Clarify limitations of Capacitor plugins in webView error html #540

@acran

Description

@acran

In the configuration reference the comments on server.errorPath state that the errorPath html won't have access to Capacitor Plugins on Android:

* On Android the html file won't have access to Capacitor plugins.

But looking through the code handling the error page it seems to me that it is loaded into the webView just like the actual app page and thus should have access to Capacitor and plugins.

And indeed a short test by setting server.errorPath to error.html (and android.minWebViewVersion too high to trigger the error page) accessing plugins works just fine with this error.html:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
	</head>
	<body>
		Device Name: <span id="name"></span>

		<script>
			Capacitor.Plugins.Device.getInfo().then(info => {
				document.querySelector('#name').textContent = info.name;
			});
		</script>
	</body>
</html>

So is this comment deprecated and there are actually no restrictions in the error html?
Or in which conditions does it apply? Only certain error conditions, older devices/webViews, ...?
At least in this case accessing plugins actually does work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions