Monday, 9 September 2013

Trying to call navigator.accelerometer in Phonegap

Trying to call navigator.accelerometer in Phonegap

Okay, so I am learning Phongap right now by going through examples. I have
about 7-8 months of javascript exposure/experience, but I am completely
new to xCode and Phonegap (about a week and a half maybe). I don't feel
that this effect my issue right now.
I don't want to out and ask, "Does navigator.accelerometer exist?", but
that almost seems like the question right now. I 'know' that is does
exist, because its called everywhere in tons of examples, but when I
actually try to call it, I get errors about it being undefined. I am doing
this, but to no avail:
var foo = navigator.accelerometer.watchAcceleration(onSuccess, onError,
options);
When I call navigator.accelerometer I get "'undefined' is not an object".
I have Phonegap installed and running when I compile, so I have no more
ideas about what the problem could be. I am assuming that this is not a
deprecated property or syntax, and based on what I see in W3C schools, I
have conclude (possibly ignorantly) that accelerometer is a property added
to navigator by Phonegap. Help is greatly appreciated. Thanks

No comments:

Post a Comment