Get data from Google Analytics, using the Core Rep

2019-04-29 16:07发布

i'm trying to get data from Google Analytics, using the Core Reporting API sdk.

https://developers.google.com/analytics/devguides/reporting/core/v3/gdataLibraries

But even the samples for IOS are not compiling on Xcode 5, and i cannot find any source code or exemple.

Sorry to ask for that, but is there anyone have a link to a demo, or tutorial to get this done?

2条回答
一夜七次
2楼-- · 2019-04-29 16:43

After a lot of try, i put a small sample of how to get data, if this can help someone:

NSString *const kKeychainItemName = @"eKit: gan";
NSString *const  kMyClientID = @"149329999999-heob9dk0o7d9999nkufaehrk99iaf9na.apps.googleusercontent.com";     // pre-assigned by service
NSString *const  kClientSecret = @"pAzA-4AAAAAcAAAmAAAAAjbA"; // pre-assigned by service

@interface sFirstViewController ()

@end

@implementation sFirstViewController {
    APPaginalTableView *_paginalTableView;
    GTLObject *myGTL;
}

- (void)viewDidLoad{
    [super viewDidLoad];
}


- (void)viewController:(GTMOAuth2ViewControllerTouch *)viewController finishedWithAuth:(GTMOAuth2Authentication *)auth
                 error:(NSError *)error {
    if (error != nil) {
        // Authentication failed
    } else {
        // Authentication succeeded
        self.auth=auth;
        [self analytics_Query];
        [viewController dismissViewControllerAnimated:TRUE completion:nil];
    }
}


- (void)analytics_Query{
    GTLServiceAnalytics *service = [[GTLServiceAnalytics alloc] init];
    service.authorizer=self.auth;
    GTLQueryAnalytics *query = [GTLQueryAnalytics queryForDataGaGetWithIds:@"ga:79891549" startDate:@"2006-01-01" endDate:@"today" metrics:@"ga:totalEvents"];
//GTLQueryAnalytics *query = [GTLQueryAnalytics queryForManagementAccountsList];

    GTLServiceTicket *ticket = [service executeQuery:query
                                   completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
                                if (error == nil) {
                                       myGTL=object;


                                       }
                                   }];
}
查看更多
走好不送
3楼-- · 2019-04-29 16:59

There is a bug reported under analytics-issues

a linker error when building with Xcode 5

it has fixed status as for 20 Sep 2013. And project manager has also given a link to IOS SDK where is should work with version > 3.01.

But after this fixed status - there are three users as for today who have the problem.

查看更多
登录 后发表回答