jeudi 23 juin 2016

Ionic IOS & Firebase (White Screen of Death)

I've hit a very difficult bug so if you're up for a challenge, read on. :)

Steps to recreate what I'm seeing:

  1. Deploy my app to a device. (this bug never happens on emulate, serve, or Xcode)
  2. Leave the app running in the background for an undetermined amount of time (usually a day or so).
  3. Sometimes when opening the app again you'll get a white screen of death.

I have a feeling that something is happening to the firebase connection and when the app opens it can't resolve $requireAuth() in the route.

Any help would be appreciated. Is there anyway issues like that can get logged somewhere?

Here is part of my route file:

            $urlRouterProvider.otherwise(function ($injector) {
                var $state = $injector.get("$state");
                $state.go("app.dashboard");
            });

           $stateProvider.state('app', {
                url: '/app',
                abstract: true,
                templateUrl: 'skinsaver/app/app.html',
                controller: 'AppController as app',
                resolve: { 
                    "userAuth": ["AppAuth", resolveUser]
                },
            });

            $stateProvider.state('app.dashboard', {
                url: '/dashboard',
                templateUrl: 'skinsaver/app/dashboard/dashboard.html',
                controller: 'DashboardController as dashboard',
            });

            function resolveUser(AppAuth){

                return AppAuth.firebaseAuth.$requireAuth();
            };

        //watch for route errors to redirect to login 
        $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {

            if(error === 'AUTH_REQUIRED'){
                event.preventDefault();
                AppAuth.returnToState = toState;
                $state.go("public.login");
            }
        });

Aucun commentaire:

Enregistrer un commentaire