Capacitor: Uncaught (in promise): SplashScreen does not have web implementation (no Promise to chatch)

Created on 19 Jun 2018  路  4Comments  路  Source: ionic-team/capacitor

Yes we know, SplashScreen is for mobile devices and probably not supported also on PWA, at least it is not documented.

But if we run SplashScreen on ionic serve, we run into this error. So having a look from PWA documentation https://capacitor.ionicframework.com/docs/basics/progressive-web-app there is

_If your app makes native plugin calls that don't have a web substitute, such as SplashScreen.show(), the app will allow those calls without crashing. Calls that return a promise will return a rejected promise, which you should be handling in your app anyways._

But neither show() nor hide() has promise to catch. We can only check for Capacitor.isPluginAvailable and omit the calls.

Same thing on Network plugin. Shouldn't work the plugins in ionic serve as for PWA's?

Most helpful comment

This works for me on StatusBar

import { Plugins, PluginRegistry, Capacitor } from '@capacitor/core';

const { SplashScreen, StatusBar }: PluginRegistry = Plugins;

if (Capacitor.isPluginAvailable('StatusBar')) { StatusBar.show() };

All 4 comments

show() should return a promise you can catch

@mlynch same issue with Plugins.StatusBar.setBackgroundColor({ color: #000000 });
ERROR Error: Uncaught (in promise): StatusBar does not have web implementation.

ERROR Error: Uncaught (in promise): StatusBar does not have web implementation.
    at resolvePromise (VM3491 polyfills.js:3193)
    at Function.ZoneAwarePromise.reject (VM3491 polyfills.js:3285)
    at CapacitorWeb.push../node_modules/@capacitor/core/dist/esm/web-runtime.js.CapacitorWeb.pluginMethodNoop (VM3493 vendor.js:74757)
    at AppComponent.push../src/app/app.component.ts.AppComponent.setStatusBarBackgroundColor (VM3494 main.js:606)
    at new AppComponent (VM3494 main.js:566)
    at createClass (VM3493 vendor.js:56191)
    at createDirectiveInstance (VM3493 vendor.js:56072)
    at createViewNodes (VM3493 vendor.js:57298)
    at createRootView (VM3493 vendor.js:57212)
    at callWithDebugContext (VM3493 vendor.js:58220)

As this is still happening with latest capacitor 1.3.0... @mlynch philosophically speaking, isn't it capacitor's job to "catch" this exception? Or better yet, shouldn't capacitor provide a web implementation for things like SplashScreen and simply be a noop?

This works for me on StatusBar

import { Plugins, PluginRegistry, Capacitor } from '@capacitor/core';

const { SplashScreen, StatusBar }: PluginRegistry = Plugins;

if (Capacitor.isPluginAvailable('StatusBar')) { StatusBar.show() };

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stripathix picture stripathix  路  3Comments

peterpeterparker picture peterpeterparker  路  3Comments

ebk46 picture ebk46  路  3Comments

json-derulo picture json-derulo  路  3Comments

Kepro picture Kepro  路  3Comments