为什么我的iOS应用会话在Google Analytics(分析)中持续30分钟?

更重要的是,我该如何解决?

这就好像背景应用程序不会结束会话。

当您的应用进入后台模式时,需要告知分析停止跟踪。

应用程序委托会有这样的东西:

-(void) applicationDidEnterBackground:(UIApplication*)application { [[GANTracker sharedTracker] stopTracker]; } 

在谷歌的Easy Tracker示例中,视图控制器在应用程序状态更改时接收通知。 跟踪应用程序进入后台时停止(大约400行)。

 if ([application applicationState] == UIApplicationStateBackground) { if (self.state == EasyTrackerStateForeground) { // Transitioned from foreground to background. Generate the app stop // event, and stop the tracker. NSLog(@"Transitioned from foreground to background."); NSError *error = nil; if (![[GANTracker sharedTracker] trackEvent:@"" action:@"" label:@"" value:0 withError:&error]) { NSLog(@"Error tracking foreground event: %@", error); } // TODO(fmela): make this time period a constant. if (![[GANTracker sharedTracker] dispatchSynchronous:2.0]) { NSLog(@"Synchronous dispatch on background failed!"); } [[GANTracker sharedTracker] stopTracker]; } self.state = EasyTrackerStateBackground; } 

它说,如果用户在30分钟内有一个事件,它会把它当作同一个会话。 所以这意味着如果用户在使用您的应用程序的30分钟内回来。

https://developers.google.com/analytics/devguides/collection/ios/v2/sessions

这可能有助于: 更新Google会话跟踪

它谈到networking,但具体提到了一个30分钟的规则。

当应用程序转到后台时使用结束会话

 applicationWillResignActive 

也许把你的web视图中的空白或东西。 ( 假设;)

保存位置并重新载入

 applicationDidBecomeActive 

或在这里阅读更多