swift - defaultTracker is nil in Google Analytics for IOS -


i'm trying set google analytics in ios app following guide google analytics ios have completed steps when run app crashes , says defaulttracker nil. following code in viewcontroller:

override func viewwillappear(animated: bool) {     super.viewwillappear(animated)     var tracker = gai.sharedinstance().defaulttracker     tracker.set(kgaiscreenname, value: nil)      var builder = gaidictionarybuilder.createscreenview()     tracker.send(builder.build() [nsobject : anyobject])  } 

in appdelegate have code should initialize regarding tracker:

func applicationdidfinishlaunching(application: uiapplication) {     // configure tracker googleservice-info.plist.     var configureerror:nserror?     gglcontext.sharedinstance().configurewitherror(&configureerror)     assert(configureerror == nil, "error configuring google services: \(configureerror)")      // optional: configure gai options.     var gai = gai.sharedinstance()     gai.trackuncaughtexceptions = true  // report uncaught exceptions     gai.logger.loglevel = gailoglevel.verbose  // remove before app release } 

does know problem might , how solve it?

thanks in advance vatan

i had same issue, fixed adding default tracker initialization @ appdelegate applicationdidfinishlaunching method below;

func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {     //...      var gai = gai.sharedinstance()     gai.trackuncaughtexceptions = true  // report uncaught exceptions     gai.defaulttracker = gai.trackerwithtrackingid("ua-xxxxx-x")     //...  } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -