Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Capacitor: this.platform.ready() not firing in production?

$
0
0

Hello

I’m having a very strange issue. I have code in my initializeApp() method that takes care of some configurations like ignoring native font zooming, disabling screen rotation, some statusbar configurations, etc. I’m also fetching some data from my backend.

When I open the app on my physical android device after running ‘ionic cap sync’ everything works fine. But after bundling my app and publishing it in the PlayStore nothing happens on the same device. No splashscreen, no data, no configurations, nothing. It seems like the function is getting ignored? I have no clue why. Here is the code in initializeApp():

initializeApp(): void {
      this.platform.ready().then(async () => {
         if (this.platform.width() > 500) {
            this.usingLargeDevice = true;
         }

         this.previousRouteService.init();

         const info = await Device.getInfo();

         if (info.platform !== 'web') {
            const hasCompletedTutorial = await this.appSettingsService.hasCompletedTutorial();
            if (!hasCompletedTutorial) {
               this.router.navigate(['/intro']);
            }

            if (!await this.appSettingsService.isReloadingAppAfterExitingTutorial()) {
               // show custom splashscreen
               this.showingSplash = true;
            }

            // disable screen rotation
            this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);

            // ignore native font zooming
            this.mobileAccessibility.setTextZoom(100);
            this.mobileAccessibility.updateTextZoom();
            this.mobileAccessibility.usePreferredTextZoom(false);

            StatusBar.setOverlaysWebView({
               overlay: true
            });
            StatusBar.setStyle({
               style: StatusBarStyle.Light
            });

            this.oneSignal.startInit(environment.oneSignal.appId, environment.oneSignal.googleProjectNumber);
            this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
            this.oneSignal.endInit();

            // hide default splashscreen
            this.splashScreen.hide();

            // hide custom splashscreen after 3 seconds
            timer(3000).subscribe(() => {
               this.showingSplash = false;
            });
         }

         this.divisionService.setDivisionPreviewModels();
      });
   }

Thanks in advance!

Update:

Added some toasts to test the signed apk. It seems like the ‘this.platform.ready().then(async () => {}’ is never hit after signing the app. Any suggestions?

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>