gpt4 book ai didi

ios - 为什么我的 iOS 应用程序在 Google Analytics 中的 session 时长超过 30 分钟?

转载 作者:可可西里 更新时间:2023-11-01 03:08:38 25 4
gpt4 key购买 nike

更重要的是,我该如何修复它?

就好像后台应用程序不会结束 session 。

最佳答案

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

Application Delegate 会是这样的:

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

在谷歌的 Easy Tracker例如, View Controller 在应用程序状态更改时接收通知。当应用程序进入后台时(第 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;
}

关于ios - 为什么我的 iOS 应用程序在 Google Analytics 中的 session 时长超过 30 分钟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9895924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com