State.go is not working on IOS


#1

The state.go is not working in ios 9. The app shows a blank page or a page that is not fully rendered. In order for the state.go to work we need to add an alert() to the screen before the state.go. This is a serious issue and needs to be resolved asap.


#2

Some error in console?
are $state injected ??


#3

@j0se there are no errors in console and yes $state is injected in controller


#4

perhaps some plugin that are bad installed ?


#5

No it not that. If I add an alert() before going to state.go() it works fine but if I just have state.go() then it does not work.


#6

could you paste the code to reproduce…

It happen at browser, device, emulator ?


#7

This is on the emulator and device.

App.js------

angular.module(‘starter’, [‘ionic’, ‘ngIOS9UIWebViewPatch’, ‘starter.controllers’])

.run(function($ionicPlatform) {

 $ionicPlatform.ready(function() {
                      
                      if (window.cordova && window.cordova.plugins.Keyboard) {
                      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
                      cordova.plugins.Keyboard.disableScroll(true);
                      
                      }
                      if (window.StatusBar) {
                      // org.apache.cordova.statusbar required
                      StatusBar.styleDefault();
                      }
                      
                      });
 
 })

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

    .state('app', {
           url: '/app',
           abstract: true,
           templateUrl: 'templates/menu.html',
           controller: 'AppCtrl'
      })
    
    .state('app.search', {
           url: '/search',
           views: {
           'menuContent': {
           templateUrl: 'templates/search.html'
           }
           }
      })
    
    .state('app.myprofile', {
           url: '/myprofile',
           views: {
           'menuContent': {
           templateUrl: 'templates/myprofile.html',
           controller: 'ProfileCtrl'
           }
           }
      })
    
    .state('app.playlists', {
           url: '/playlists',
           views: {
           'menuContent': {
           templateUrl: 'templates/landingpage.html',
           controller: 'PlaylistsCtrl'
           }
           }
     })
    
    .state('app.viewshopitems', {
           url: '/viewshopitems',
           views: {
           'menuContent': {
           templateUrl: 'templates/viewshopitems.html',
           controller: 'ViewGroceryCtrl'
           }
           }
     })
    
    .state('app.viewshopitemshared', {
           url: '/viewshopitemshared',
           views: {
           'menuContent': {
           templateUrl: 'templates/viewshopitemshared.html',
           controller: 'ViewSharedGroceryCtrl'
           }
           }
     })
    
    .state('app.grocerylist', {
           url: '/grocerylist',
           views: {
           'menuContent': {
           templateUrl: 'templates/grocerylist.html',
           controller: 'GroceryListCtrl'
           }
           }
      })
    
    .state('app.registration', {
           url: '/registration',
           views: {
           'menuContent': {
           templateUrl: 'templates/register.html',
           controller: 'RegistrationCtrl'
           }
           }
     })
    
    .state('app.registration2', {
           url: '/registration2',
           views: {
           'menuContent': {
           templateUrl: 'templates/register2.html',
           controller: 'RegistrationCtrl'
           }
           }
           })
    
    .state('app.mysuburbs', {
           url: '/mysuburbs',
           views: {
           'menuContent': {
           templateUrl: 'templates/mysuburbs.html',
           controller: 'SuburbCtrl'
           }
           }
      });
    // if none of the above states are matched, use this as the fallback
    //$urlRouterProvider.otherwise('/app/registration2');
    //$urlRouterProvider.otherwise('/app/playlists');
    $urlRouterProvider.when('','/app/playlists');

});

Controller ----

.controller(‘AppCtrl’, function($scope, $state, $ionicModal, $timeout, GCMService, cordova, OfflineUpdateGroceryListService){
var isLoggedIn = “”;
var UserID = “”;

        $scope.$on('$ionicView.loaded', function(){
                   checknetworkStatus();
                   
                   isLoggedIn = window.localStorage.getItem('isLoggedIn');
                   UserID = window.localStorage.getItem("UserID");

                   if(isLoggedIn == null || isLoggedIn == undefined || isLoggedIn == ""){
                   alert(isLoggedIn);
                   $state.go("app.registration");
                   }
                   else{
                   
                   cordova.devicered();
                   QuickLogin();
                   }
                   
                   });
        
        $scope.$on('$ionicView.enter', function(){
                   
         });
        
        $scope.goshare = function(){
            ShareEasyShopping();
        }
        
        })

#8

not seeing anything right off the top. does it work in Android? in JSFiddle?


#9

@lintonachmad1

Just for testing, comment out the checkNetworkStatus(0 and also the two localStorage getItem lines. See if that does anything.

My hunch is that either the networkStatus function or the getItem functions may be causing issues. Do the localstorage items exist? If not, you may want to check before you try to get the item.

if (window.localStorage.isLoggedIn) {
    isLoggedIn = window.localStorage.getItem('isLoggedIn');
} else {
    isLoggedIn = "";
}

Try that. Also, show the template for the view. May be rouge HTML or CSS causing issues.


#10

Hi @lintonachmad1 , I know its old but have you been able to find a solution ? Thanks