ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
https://capacitorjs.com
MIT License
12.14k stars 1.01k forks source link

bug: Splashscreen does not hide #3772

Closed mbakker96 closed 3 years ago

mbakker96 commented 3 years ago

Bug Report

Capacitor Version

$ npx cap doctor
πŸ’Š   Capacitor Doctor  πŸ’Š

Latest Dependencies:

  @capacitor/cli: 2.4.2
  @capacitor/core: 2.4.2
  @capacitor/android: 2.4.2
  @capacitor/electron: 2.4.2
  @capacitor/ios: 2.4.2

Installed Dependencies:

  @capacitor/cli 2.4.2
  @capacitor/core 2.4.2
  @capacitor/android 2.4.2
  @capacitor/ios 2.4.2
  @capacitor/electron not installed

[success] Android looking great! πŸ‘Œ
  Found 1 Capacitor plugin for ios:
    cordova-plugin-whitelist (1.3.4)
[success] iOS looking great! πŸ‘Œ

Platform(s)

[ x ] iOS [ ] Android ? [ ] Web

Not tested on android

Current Behavior

I disabled the autohide function in the capacitor.config.json file because the splash screen most be visible until a resolve of an API response. To hide the splash screen I used Splashscreen.hide() (capacitor) and this.splashscreen.hide (ionic-native). By both the splash screen did not hide.

Expected Behavior

When calling Splashscreen.hide, the splash screen should hide and the application should be visible.

Code Reproduction

https://github.com/mbakker96/splashscreen

Other Technical Details

npm --version output: 6.14.6

node --version output: v10.22.0

pod --version output (iOS issues only): 1.9.3

Additional Context

I only tested it on iOS and to mock an API request I used the timeout function. The example application is not my real application, but I have made a mock application to display the issue.

jcesarmobile commented 3 years ago

You are using the plugin wrong, check the docs.

You don't have to import the plugin directly from core, but the Plugins object that contains all Capacitor plugins.

Replace import {SplashScreen} from '@capacitor/core'; with

import { Plugins } from '@capacitor/core';
const { SplashScreen } = Plugins;

This has been a common problem, probably related to vs code or other editors making auto imports from the wrong place. Luckily in Capacitor 3 you'll be able to import the plugins directly instead of using the Plugins object.

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.