ionic-team / capacitor-plugins

Official plugins for Capacitor ⚡️
517 stars 583 forks source link

bug: Android: Geolocation.getCurrentPosition() hides splash screen #372

Closed vanessag closed 2 years ago

vanessag commented 3 years ago

Bug Report

Capacitor Version

Latest Dependencies:

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

Installed Dependencies:

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

[success] Android looking great! 👌
  Found 9 Capacitor plugins for ios:
    @capacitor-community/admob (1.3.1)
    @capacitor-community/apple-sign-in (1.0.0)
    @capacitor-community/facebook-login (1.1.0)
    @capacitor-community/firebase-analytics (0.2.1)
    @capacitor-community/firebase-crashlytics (0.3.0)
    @codetrix-studio/capacitor-google-auth (2.1.3)
    cordova-open-native-settings (1.5.3)
    cordova-plugin-screen-orientation (3.0.2)
    es6-promise-plugin (4.2.2)
[success] iOS looking great! 👌

Platform(s)

Android only.

Current Behavior

1) Set capacitor config to manually hide splash screen: "launchAutoHide": false 2) Call Geolocation.getCurrentPosition()anywhere in the code 3) Splash screen will be hidden when the geolocation access prompt is shown.

Expected Behavior

Geolocation.getCurrentPosition() should not hide the splash screen. I would expect the geolocation access prompt to appear over the splash screen like it does in iOS.

Code Reproduction

See 'Current Behavior' section.

Other Technical Details

Ionic:

   Ionic CLI                     : 6.13.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.6.3
   @angular-devkit/build-angular : 0.1102.6
   @angular-devkit/schematics    : 11.2.6
   @angular/cli                  : 11.2.6
   @ionic/angular-toolkit        : 3.1.1

Capacitor:

   Capacitor CLI   : 2.4.7
   @capacitor/core : 2.4.7

Utility:

   cordova-res : 0.15.3
   native-run  : 1.3.0

System:

   NodeJS : v14.16.1 (/usr/local/Cellar/node@14/14.16.1/bin/node)
   npm    : 6.14.12
   OS     : macOS Catalina

npm --version output: 6.14.12

node --version output: 14.16.1

jcesarmobile commented 3 years ago

I can reproduce, it's caused because the splash gets destroyed on pause event, and the permission prompts trigger pause event.

Anyway, requesting permissions on app launch is not recommended, you should wait until the user is going to do something that requires the permission

https://developer.android.com/training/permissions/requesting#workflow_for_requesting_permissions

vanessag commented 3 years ago

I agree with you but my app requires the location when the app starts because we are displaying information related to the user's location (if they allow of course). When the splash screen hides prematurely it leaves a blank white screen until the home page loads in.

jcesarmobile commented 2 years ago

This is no longer an issue on Capacitor 4 with version 4 of geolocation and splash-screen plugins if using the new Android 12 Splash Screen API.

ionitron-bot[bot] commented 2 years 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 the plugin, please create a new issue and ensure the template is fully filled out.