无法使用Google Analytics插件与PhoneGap 2.0配合使用(Cannot get Google Analytics Plugin to Work with PhoneGap 2.0

编程入门 行业动态 更新时间:2024-10-13 22:24:20
无法使用Google Analytics插件与PhoneGap 2.0配合使用(Cannot get Google Analytics Plugin to Work with PhoneGap 2.0)

我曾经使用过PhoneGap 1.9并且成功使用了Google Analytics插件 。

我最近升级到PG 2.0(这样我就可以使用新的Urban Airship插件),现在我的Google Analytics似乎已经停止运行了。

不幸的是,我认为这与通过JavaScript初始化插件有关。 经过一番挫折后,我得到了我的应用程序,最终编译 但是,在我的JavaScript中初始化Google Analytics插件 ,我的应用程序几乎停止响应。

我希望我可以给你们一些错误消息或者其他东西,但我没有得到编译器错误,我没有得到任何JavaScript错误。 当我使用以下两行时,应用程序不响应:

g_objGoogleAnalytics = window.plugins.googleAnalyticsPlugin; g_objGoogleAnalytics.startTrackerWithAccountID("UA-XXXXXXXX-X");

如果我评论这两行,应用程序中的其他所有内容都像魅力一样。

有没有人在PG 2.0下使用Google Analytics插件? 如果是这样,任何建议或步骤将不胜感激。

更新:我使用try / catch添加了一些错误检查,并且每当我执行上面两行代码时,控制台日志现在都声明“undefined不是对象”。

I had been using PhoneGap 1.9 for a while and was successfully using the Google Analytics Plugin.

I recently upgraded to PG 2.0 (so that I could use the new Urban Airship plugin) and now my Google Analytics seems to have stopped functioning.

Unfortunately, I think it has something to do with the initialization of the plugin via JavaScript. After some frustration I got my app to finally compile. But, my app pretty much just stops responding after the Google Analytics plugin is initialized in my JavaScript.

I wish I could give you guys some error messages or something, but I am getting no compiler errors and I am getting no JavaScript errors. The app just does not respond when I use the following two lines:

g_objGoogleAnalytics = window.plugins.googleAnalyticsPlugin; g_objGoogleAnalytics.startTrackerWithAccountID("UA-XXXXXXXX-X");

If I comment these two lines out, everything else in the app works like a charm.

Has anyone got the Google Analytics plugin working under PG 2.0? If so, any advice or steps would be greatly appreciated.

UPDATE: I added some error checking with try/catch and the console log now states "undefined is not an object" whenever I execute the above two lines of code.

最满意答案

我自己找到了答案。 github上的kieranshaw在JS文件中将关键字“PhoneGap”更改为“codova”,这似乎混淆了这个问题。 您可以在此处查看更改: https : //github.com/kieranshaw/phonegap-plugins/commit/cc4424410869912ff278de0228a6c328b1296fbe

I found the answer myself. kieranshaw on github changed the keyword "PhoneGap" to "codova" in the JS file and that seemed to mix the issue. You can see the changes here: https://github.com/kieranshaw/phonegap-plugins/commit/cc4424410869912ff278de0228a6c328b1296fbe

更多推荐

本文发布于:2023-08-06 17:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1452761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插件   Analytics   Google   PhoneGap   Work

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!