Skip to content

Instantly share code, notes, and snippets.

@sean-hill
Last active April 16, 2017 17:25
Show Gist options
  • Save sean-hill/e4b97c30ff628d3ae694 to your computer and use it in GitHub Desktop.
Save sean-hill/e4b97c30ff628d3ae694 to your computer and use it in GitHub Desktop.
Hide Splashscreen in Ionic App with ngCordova
// Your App
angular.module('your-app', ['ionic', 'ngCordova'])
.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
$stateProvider
.state("home", {
url: "/home",
controller: "HomeCtrl",
templateUrl: "templates/home.html",
resolve: {
splash: function(AppInit) {
return AppInit.splash();
}
}
})
// Fallback to this route
$urlRouterProvider.otherwise("/home");
})
;
.factory('AppInit', function ($q, $cordovaSplashscreen, $ionicPlatform, $timeout) {
return {
splash: function() {
var deferred = $q.defer();
$ionicPlatform.ready(function(){
$timeout(function(){
$cordovaSplashscreen.hide();
deferred.resolve();
}, 500);
});
return deferred.promise;
}
};
})
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.tabs158846" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>tabs</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">
Ionic Framework Team
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<!-- IMPORTANT (Make sure to add splashscreen plugin too) -->
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="ShowSplashScreenSpinner" value="false"/>
<!-- IMPORTANT -->
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
</widget>
Hide Splashscreen in Ionic App
@mohanchalla
Copy link

Hi sean-hill
Whether this has any effect if we set 500 milliseconds in lower version devices because it may take some time to load may be more than 500 milliseconds. Is is it advisable to hard code timeout for splash screen. Please help me out this issue. Thanks in Advance.

@dhtor
Copy link

dhtor commented Feb 2, 2017

Thank you for this! Works great! I spent hours trying to get this to work in other ways.

@subratastack
Copy link

This was a great help. I had to spent so many hours to find the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment