Closed femiji closed 8 years ago
What platform are you running on? Ios or Android?
Android
I just tested using the latest cordova 5.4.0 and I was able to successfully use the plugin. Are you accessing the navigator.analytics object after the device ready event?
document.addEventListener('deviceready', function () {
alert(navigator.analytics);
}, false);
also for more info from the cordova docs:
The deviceready event fires once Cordova has fully loaded. Once the event fires, you can safely make calls to Cordova APIs. Applications typically attach an event listener with document.addEventListener once the HTML document's DOM has loaded.
https://cordova.apache.org/docs/en/4.0.0/cordova/events/events.deviceready.html
Let me know if this resolves your issue. Thanks,
-Craig
Thanks for the speedy response. It caught me off guard.
Here is what I got The Connection To The Server Was Unsuccessful. (file:/android_asset/www/index.html)
Is that what I should get instead of undefine?
Thanks.
Hmm, I have never received that when using the plugin. I would recommend trying in a clean project.
cordova create test-project
cd test-project
cordova platform add android
cordova build android
cordova run android
then verify the app is working before adding the plugin, then run:
cordova plugin add com.cmackay.plugins.googleanalytics
then add the following to in www/js/index.js
document.addEventListener('deviceready', function () {
alert(navigator.analytics);
}, false);
and build again then see if it is working.
I think it is best to try the above to verify the environment is working properly. Let me know what you find.
now the alert box didn't pop up.
this is the bottom of my index.html
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
document.addEventListener('deviceready', function () {
alert(navigator.analytics);
}, false);
There are many potential issues that could occur in troubleshooting a hybrid app so it is difficult for me to provide any help. If the deviceready event is not firing in a new app then you must have a problem with your environment or project setup. I think stackoverflow may provide more help.
http://stackoverflow.com/questions/8982728/deviceready-not-working-in-phonegap-application-how-to
I have followed the step for setting up the analytic test here
https://github.com/cmackay/google-analytics-plugin/issues/1
and I got undefined as the output of alert(navigator.analytics)
I am using Cordova 5.3.3
Does the plugin work with cordova 5.3.3