最後,我得到了解決方案!
我所做的是:
- 按照https://developers.google.com/analytics/devguides/collection/ios/v3/
從指令的步驟1和2,我不知道這是否是相關的,但在步驟1中,我把SDK在App的類文件夾文件(這裏是AppDelegate.h ...)
在步驟2,記得把開頭:
#import "GAI.h"
En MainViewController。m將在開始
#import "GAI.h"
#import "GAIFields.h"
#import "GAITracker.h"
#import "GAIDictionaryBuilder.h"
然後註釋掉行:
/*
- (void) webViewDidStartLoad:(UIWebView*)theWebView
{
return [super webViewDidStartLoad:theWebView];
}
- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
{
return [super webView:theWebView didFailLoadWithError:error];
}
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
*/
而且,最後,行
return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
前插入這樣的:
NSString* path = [NSString stringWithFormat:@"%@",request];
if([path hasPrefix:@"mailto"]==NO) {
NSRange range = [path rangeOfString:@"/" options:NSBackwardsSearch];
NSString* fileName = [NSString stringWithFormat:@"/%@",[path substringFromIndex:range.location + 1]];
[[GAI sharedInstance].defaultTracker set:kGAIScreenName
value:fileName];
[[GAI sharedInstance].defaultTracker
send:[[GAIDictionaryBuilder createAppView] build]];
}
就是這樣。現在你可以關注你的應用程序,甚至是科爾多瓦處理的內嵌頁面。
我得給我的兄弟和http://blog.fltlab.net/2012/04/10/phonegap-and-googleanalytics/誰給了我提示的人的學分。
更新:更新到Xcode 5.1後,科爾多瓦3.4(我在2.9),我不得不重拍我的科爾多瓦應用程序,並重復所有這些步驟;但我必須在步驟1鏈接另一個庫(libsqlite3.dylib)。