Phonegap 3.1 - Unable to hide splash screen on device

Using phonegap 3.1 I'm trying to hide the splash screen when the device is ready:

document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { navigator.splashscreen.hide(); } 

But it returns:

Unable to call 'hide' method from undefined

The navigator object does not include the splashscreen attribute.

I tried it on the phone book 2.9 and it works great.

+7
android cordova
source share
6 answers

After research and experimentation, this is what we had to do to make it work:

cordova plugin add org.apache.cordova.splashscreen

cordova build

Then the cord assembly added the wrong lines to the config.xml file. Therefore, we had to change it to the following:

  <feature name="SplashScreen"> <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" /> </feature> 

And in your main business

  super.setIntegerProperty("splashscreen", R.drawable.splash); super.setIntegerProperty("splashScreenDelay", 10000); //time to display the splash 

Finally, we were able to use the hide method from javascript.

+10
source share

Are you using the CLI to add the SplashScreen plugin? You must add the plugin with $ cordova plugin add org.apache.cordova.splashscreen (copy the plugin code from plugins.cordova.io to /yourApp/plugins/org.apache.cordova.splashscreen/, and then later cordova build to copy the code plugin to the appropriate platform location.

+3
source share

If you use the phonegap assembly, instead of doing

 cordova plugin add ... 

from the command line, you need to add the plugin and function in config.xml :

 <gap:plugin name="org.apache.cordova.splashscreen" /> <feature name="SplashScreen"> <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" /> <param name="ios-package" value="CDVSplashScreen" /> </feature> 
+1
source share

The only thing I can guess is double check that you have <script type="text/javascript" charset="utf-8" src="cordova.js"></script> in the head of your HTML, which calls this js. Sorry, not yet confused 3.1.

0
source share

Add this:

 <preference name="SplashScreen" value="splash.png" /> <preference name="SplashScreenDelay" value="3000" /> 

Navigator .splashscreen.hide () does not work for me either.

UPDATE: navigator.splashscreen.hide () only works when building online (building phone calls).

0
source share

After upgrading to Phonegap Desktop 0.3.6, I had a similar problem and one of my old applications got stuck on the splash screen. In the configuration window, it displayed the correct name and version of the application and was updated as soon as I changed the config.xml file. In the console, I had only one error: 500 for http://localhost:3000/cordova_plugins.js

The new app works great.

I have tried all of the above:

  • plugin and screen saver configuration
  • adding cordova.js and cordova_plugins.js to index.html . This is no longer necessary, since many versions are back - the assembly does it for you.
  • In the platforms/android/assets/www folder, cordova.js and cordova_plugins.js files cordova.js cordova_plugins.js .
  • config.xml contains <content src="index.html" />

In the end, I decided to completely delete the platforms folder and run cordova platform add android again. I think it is safe to do this after every Phonegap update.

0
source share

All Articles