IOS cordova issue. Can't find variable


#1

Hi,
I am getting error while testing app on IOS device

ReferenceError: Can’t find variable: cordova


#3

are you loading cordova.js in the header of your index.html?


#4

yes i am using in head tag


#5

then you are not waiting until the device/ionic is ready.

maybe you have native functionality in a controller / service which is executed before that.
http://ionicframework.com/docs/api/utility/ionic.Platform/

You should see the line of code the error occurs… maybe that gives you a hint.


#6

Can you post your header file and also post the code of where you reference the cordova variable at all? That can help us determine exactly why it might not be showing up too. Though it’s likely you are using it outside of device ready like @bengtler was saying.


#7

Hello same error on IOS DEVICE.

ReferenceError: Can’t find variable: cordova
Do you have any recommandation ?

I bootstrap my app like

    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/ionic-service-core/ionic-core.js"></script>
    <script src="lib/ionic-service-push/ionic-push.js"></script>
    <script src="cordova.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.js"></script>

I bootstrap my app with :

if (window.cordova) {
        document.addEventListener('deviceready', function() {
            console.log("device ready");
                        angular.element(document).ready(function() {
                        angular.bootstrap(document.body, ['MyApp']);
                    });
        }, false);
    }

I’m stuck with this error without understand why …


#8

Have you found a solution? I have the same problem…


#9

i think the problem is what you should put the cordova.js above ib/ngCordova/dist/ng-cordova.js like this

<script src=“lib/ionic/js/ionic.bundle.js”></script>
<script src=“lib/ionic-service-core/ionic-core.js”></script>
<script src=“lib/ionic-service-push/ionic-push.js”></script>
<script src=“lib/ngCordova/dist/ng-cordova.js”></script>
<script src=“cordova.js”></script>

Sorry for my bad english


#10

check Your internet connection working or not if You Are livereloading in ios