如何修复Ionic App在浏览器上但在Android上不起作用没有控制台错误

时间:2019-04-01 09:00:41

标签: android cordova ionic-framework

我正在使用ionic serve部署我的ionic应用程序,它工作正常,但是当我在android模拟器上运行时,它似乎卡在了初始加载中,控制台中没有错误。

这是初始加载代码

$rootScope.loader = function(){
  try { 
      $scope.ajaxRequest = A.Device.get({action: 'config', dID: oneSignalID});
      $scope.ajaxRequest.$promise.then(function(){                                          
            $localstorage.setObject('config', $scope.ajaxRequest.config);
            $localstorage.setObject('app', $scope.ajaxRequest.app);
            app = $scope.ajaxRequest.app;
            $localstorage.setObject('prices', $scope.ajaxRequest.prices);
            max_ad = $scope.ajaxRequest.ad;
            var isAndroid = ionic.Platform.isAndroid();
            if(isAndroid){
                adMobI = $scope.ajaxRequest.adMobA;
            } else {
                adMobI = $scope.ajaxRequest.adMobI;
            }
            var l1 = $scope.ajaxRequest.lang;
            var l2 = $scope.ajaxRequest.alang;
            console.log(l2);
            angular.forEach(l1,function(entry) {                      
                l1[entry.id].text = entry.text.replace("'", "'");  
            }); 
            angular.forEach(l2,function(entry) {                      
              l2[entry.id].text = entry.text.replace("'", "'");        
            });                                                 
            $localstorage.setObject('lang', l1);
            $localstorage.setObject('alang', l2);
            $rootScope.alang = l2;
            $rootScope.appConfig = $scope.ajaxRequest.config;
            $localstorage.setObject('user', $scope.ajaxRequest.user);
            $localstorage.setObject('premium_package', $scope.ajaxRequest.premium_package);
            $localstorage.setObject('credits_package', $scope.ajaxRequest.credits_package);                 
            $localstorage.setObject('account_basic', $scope.ajaxRequest.account_basic);
            $localstorage.setObject('account_premium', $scope.ajaxRequest.account_premium);
            $localstorage.setObject('gifts', $scope.ajaxRequest.gifts);
            $rootScope.appGifts = $scope.ajaxRequest.gifts;
            rt = new Pusher($scope.ajaxRequest.config.pusher, {
              encrypted: true,
              cluster: config.pusher_clauster
            });
            channel = rt.subscribe($scope.ajaxRequest.config.pusher);

            if($scope.ajaxRequest.user != ''){
                $localstorage.setObject('usPhotos', $scope.ajaxRequest.user.photos);
                usPhotos = $scope.ajaxRequest.user.photos;
                sape = $scope.ajaxRequest.user.slike;
                var rtnotification = 'notification'+$scope.ajaxRequest.user.id;
                channel.bind(rtnotification, function(data) {
                    if(data.id != current_user_id ){
                        if(!$('.chatNotification').hasClass('is-visible')){     
                            $('.chatNotification').removeClass('is-visible');
                            $('.chatNotificationPhoto').removeClass('sblur');   
                            $('.chatNotificationPhoto').css('background-image', 'url('+ data.icon +')');
                            $('.chatNotificationContent').text(data.message);
                            setTimeout(function(){
                                if(!$('.chatNotification').hasClass('is-visible')){
                                    $('.chatNotification').addClass('is-visible');
                                }
                            },500);             
                            setTimeout(function(){
                                if($('.chatNotification').hasClass('is-visible')){
                                    $('.chatNotification').removeClass('is-visible');
                                }
                            },6000);                    
                        }
                    }
                });
                var rtvisit = 'visit'+$scope.ajaxRequest.user.id;
                channel.bind(rtvisit, function(data) {  
                    if(!$('.chatNotification').hasClass('is-visible')){ 
                        $('.chatNotification').removeClass('is-visible');
                        $('.chatNotificationPhoto').removeClass('sblur');   
                        $('.chatNotificationPhoto').css('background-image', 'url('+ data.icon +')');
                        $('.chatNotificationContent').text(data.message);
                        setTimeout(function(){
                            if(!$('.chatNotification').hasClass('is-visible')){
                                $('.chatNotification').addClass('is-visible');
                            }
                        },500);             
                        setTimeout(function(){
                            if($('.chatNotification').hasClass('is-visible')){
                                $('.chatNotification').removeClass('is-visible');
                            }
                        },6000);
                    }                   
                }); 
                var rtlike = 'like'+$scope.ajaxRequest.user.id;
                channel.bind(rtlike, function(data) {
                    if(!$('.chatNotification').hasClass('is-visible')){     
                        $('.chatNotification').removeClass('is-visible');
                        if(user.premium == 1){
                            $('.chatNotificationPhoto').removeClass('sblur');   
                        } else {
                            $('.chatNotificationPhoto').addClass('sblur');
                        }                           
                        $('.chatNotificationPhoto').css('background-image', 'url('+ data.icon +')');
                        $('.chatNotificationContent').text(data.message);
                        setTimeout(function(){
                            if(!$('.chatNotification').hasClass('is-visible')){
                                $('.chatNotification').addClass('is-visible');
                            }
                        },500);             
                        setTimeout(function(){
                            if($('.chatNotification').hasClass('is-visible')){
                                $('.chatNotification').removeClass('is-visible');
                            }
                        },6000);                        
                    }
                });                                                                             
                $state.go('home.explore');                  
            } else {
                $state.go('intro');
            }
            $rootScope.logo = app.logo;
            var style = document.createElement('style');
            style.type = 'text/css';
            style.innerHTML = '.bg-tinder {background:'+app.first_color+'; background: -moz-linear-gradient(left,  '+app.first_color+' 0%, '+app.second_color+' 100%);background: -webkit-linear-gradient(left,  '+app.first_color+' 0%,'+app.second_color+' 100%); background: linear-gradient(to right,  '+app.first_color+' 0%,'+app.second_color+' 100%); color:#fff }';
            document.getElementsByTagName('head')[0].appendChild(style);        
      },
      function(){}
      )      
  }
  catch (err) {
    console.log("Error " + err);
  }     
}

我希望该应用程序进入$ state.go('intro');在初始负载上。我尝试重新安装cordova白名单。

0 个答案:

没有答案