Search code examples
ioscordovapluginsstatusbar

Cant find variable: Statusbar Phonegap 3.3.0-0.19.3 while older version is present on iPhone


This is my first post on Stackoverflow :).

I have phonegap app with some javascript code, it basically displays splash page and changes color of status bar and then finally redirects to mobile web-app.

Now I have older version of app installed on my iPhone; when I am trying to run new version of app from Xcode it throws an error Cant find variable: Statusbar, however if I delete older app and try to run the app from Xcode it works fine.

Below is my javascript code:

<html>
<body>
    <script type="text/javascript" src="phonegap.js"></script>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {
            try{
            StatusBar.overlaysWebView(false);
            }catch(e){
                alert(e.message); //displays: can't find variable:Statubar.
            }
            StatusBar.backgroundColorByHexString("#BE1313");
            StatusBar.show();
            navigator.splashscreen.hide();
            window.location.href="https://m.example.com/";
        }
    </script>
</body>

Below is my config.xml file:

<preference name="show-splash-screen-spinner" value="false" />
<preference name="auto-hide-splash-screen" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<feature name="SplashScreen">
    <param name="ios-package" value="CDVSplashScreen" />
    <param name="onload" value="true" />
</feature>
<feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<gap:plugin name="com.phonegap.plugin.statusbar" />

Please ask for more information if I am missing something and suggest any leads to resolve this.

Pardon me for any mistakes in post.


Solution

  • As suggested by @frank I removed pohonegap.js and it worked for me perfectly !