Google Analytics不会在Swift中初始化

yan*_*iks 6 google-analytics ios swift xcode6 ios8

我的新swift应用程序由于某种原因未初始化Google Analytics.我在项目中为所有GAnalytics文件创建了一个桥接标题:

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
Run Code Online (Sandbox Code Playgroud)

这是我的AppDelegate.swift文件的一部分:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    if NSUserDefaults.standardUserDefaults().boolForKey("allowganalytics") {
        GAI.sharedInstance().trackUncaughtExceptions = true
        GAI.sharedInstance().dispatchInterval = 10
        var tracker = GAI.sharedInstance().trackerWithTrackingId("UA-******-1")
        tracker.send(GAIDictionaryBuilder.createEventWithCategory("ui_action", action: "app_launched",label:"launch",value:nil).build())
    }
    return true
}
Run Code Online (Sandbox Code Playgroud)

如果我检查设备的系统日志,我不会说Google Analytics发生任何事情.

Alv*_*ese 8

这样做.

     GAI.sharedInstance().trackerWithTrackingId("UA-*******-1")
                GAI.sharedInstance().defaultTracker..allowIDFACollection = true
GAI.sharedInstance().defaultTracker.send(GAIDictionaryBuilder.createEventWithCategory("ui_action", action: "app_launched",label:"launch",value:nil).build())
Run Code Online (Sandbox Code Playgroud)