Open vespino opened 10 years ago
I'm having the same issue. To test it, I created a new app that was just a single page based on the repo's example and it's still not working. When I log the 'result' or 'error' from the success or error callbacks, they are both null.
Hi - I'm successfully using the plugin and happened across your issue. I think I know the issue - do you have the line of code that registers the onDeviceReady method? I noticed this is missing from the README; it should definitely be added in in order to have a true working example:
function onDeviceReady() {
gaPlugin = window.plugins.gaPlugin;
gaPlugin.init(successHandler, errorHandler, "YOUR ID", 10);
}
function initialize() {
// PhoneGap will call this for you it has fully loaded and is ready for plugin interaction
document.addEventListener("deviceready", onDeviceReady, false);
}
and then HTML:
<body onload="initialize();">
// other HTML
</body>
My problem seem to be "app.initialize();" which had to be at the and of the onDeviceReady function. It works perfectly now!
My issue turned out to be some conflict with FastClick https://github.com/ftlabs/fastclick
For some reason, it was preventing it from ever calling 'onDeviceReady' so the gaPlugin object was never being created. I removed FastClick and it seemed to work fine and called it good. :)
Ah, ok. Strange, but I've run across issues like that before. What usually works for me if I introduce something new and see odd behavior, especially with onDeviceReady is to slowly work my way backwards until it's resolved.
I have tried the following integration (Phonegap Build) but the plugin doesn't seem to work:
In my config.xml: [gap:plugin name="com.adobe.plugins.gaplugin" /]
In my javascript file: function onDeviceReady() { app.initialize(); gaPlugin = window.plugins.gaPlugin; gaPlugin.init(successHandler, errorHandler, "UA-12345678-1", 10);
}
I have created the success and error functions, but both don't seem to be fired. So no success and no error.
What can I be doing wrong?