How to avoid white screen after splash screen


#1

master controller is “Appctrl” .i added localStorage for store token key.when app open have to check that.if token expired.have to direct to login page.functions are working.but after splash screen, until authentication function finish,the screen was white background.how to avoid it?code pattern or any idea for it? thank you

here is controllers.js

angular.module(‘app.controllers’, [])

/**
*App Controller 1st run
*/
.controller(‘AppCtrl’, function ($scope, $state, $ionicPopup, AuthService, AUTH_EVENTS,$ionicPlatform,$ionicLoading, $compile, $cordovaGeolocation,GetDeviceInfo,CurrentLocation) {

   console.log("app controller");
  
    $scope.username = AuthService.username();
    
    
    $scope.$on(AUTH_EVENTS.notAuthenticated, function(event) {
        AuthService.logout();
    });
    
    $scope.setCurrentUsername = function(name) {
        $scope.username = name;
    };
   
});

/**************************************************/

this is my index.html

<body ng-app="app" ng-controller="AppCtrl">
    <ion-nav-view></ion-nav-view>
</body>

/*******************************************/
this is app.js file

.config(function($stateProvider, $urlRouterProvider,USER_ROLES) {
    $stateProvider

        .state('home', {
            url: "/home",
            templateUrl: "templates/home.html",
            controller: 'AppCtrl'
        })
        .state('login', {
            url: "/login",
            controller: 'LoginCtrl',
            templateUrl: "templates/login.html"
        })
        .state('main', {
            url: "/main",
            controller: 'MainCtrl',
            templateUrl: "templates/main.html"
        });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/main');
})

#2

Dont’ depend on Auto Hide for the splashscreen, and make it
yourself at the end of authentication function.

For iOS:

<preference name="AutoHideSplashScreen" value="false" />

For Android:
set a large number for the splash screen delay time, like 1 minute

The command to hide for both:

navigator.splashscreen.hide()

or

$cordovaSplashscreen.hide();

I hope thats help
Good Luck


#3

thank you @ayman .i will try.