简体   繁体   English

什么时候在iOS applicationDidBecomeActive之后立即调用applicationDidEnterBackground?

[英]When in iOS applicationDidEnterBackground called immediately after applicationDidBecomeActive?

in our app we are logging (with an external analytics service) every time the user open our app.在我们的应用程序中,每次用户打开我们的应用程序时,我们都会记录(使用外部分析服务)。 However, we have noticed that there are many weird app sessions (almost 15% of total sessions).但是,我们注意到有许多奇怪的应用会话(几乎占总会话的 15%)。

Following the device timestamp of the events, the following methods are called:在事件的设备时间戳之后,将调用以下方法:

application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)

applicationDidBecomeActive(_ application: UIApplication)

viewDidAppear(_ animated: Bool) // App Splash Screen

applicationDidEnterBackground(_ application: UIApplication)

Looking at the timestamp, from didFinishLaunchingWithOptions to applicationDidEnterBackground there is just a very short delay (<1 sec).查看时间戳,从didFinishLaunchingWithOptionsapplicationDidEnterBackground的延迟非常短(<1 秒)。

Our hypothesis is that the system sometimes wakes up the app without it being actually opened and "seen" by the user.我们的假设是,系统有时会在应用程序未被用户实际打开和“看到”的情况下唤醒应用程序。 But we can't find any docs about this kind of use case, and we can't reproduce ourself the issue.但是我们找不到任何关于这种用例的文档,我们也无法自己重现这个问题。 Did someone have experienced something similar?有人经历过类似的事情吗?

EDIT : I want to add that these suspicious sessions are often (but not always) linked to an app update.编辑:我想补充一点,这些可疑会话通常(但不总是)链接到应用程序更新。

I'm not sure...我不确定...

I suppose if app wasn't user terminated nor suspended but was just put out of memory because other apps needed the memory, then almost a launch options can wake the app up if needed.我想如果应用程序没有被用户终止或暂停,而是因为其他应用程序需要 memory 而被从 memory 中删除,那么几乎一个启动选项可以在需要时唤醒应用程序。 Some examples:一些例子:

Take a look at here and see what launch options are possible for your app.看看这里,看看您的应用程序可以使用哪些启动选项。 I'm not sure if all of them can actually launch the app or what...我不确定他们是否真的可以启动应用程序或者什么......

If you want more visibility into this, then make sure for future you log the launchoptionskey that caused the app to get launched...如果您想对此有更多了解,请确保将来记录导致应用程序启动的 launchoptionskey ...

You need more info - I would extend your logging to dump the launchOptions dictionary in您需要更多信息-我会扩展您的日志记录以将launchOptions字典转储到

application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)

Looking at UIApplication.LaunchOptionsKey , there are a lot of options which may be involved.查看UIApplication.LaunchOptionsKey ,可能涉及很多选项。 Note, as the help says: The contents of this dictionary may be empty in situations where the user launched the app directly注意,如帮助所说:在用户直接启动应用程序的情况下,该词典的内容可能为空

 if let lop = launchOptions { 
   let toLog = lop.map{"\($0.0.rawValue) \($0.1)"}.joined(separator:"\n")
   // log the options
...}

I did have an idea this might be related to previewing in AppSwitcher but that doesn't seem to trigger didFinishLaunchingWithOptions , unless you actually bring the app to the front.我确实知道这可能与在 AppSwitcher 中进行预览有关,但这似乎不会触发didFinishLaunchingWithOptions ,除非您实际上将应用程序置于最前面。 Maybe some split-screen stuff on iPad?也许 iPad 上有一些分屏的东西? It feels like the app is being invoked in a context where it can't get past the launch screen.感觉就像是在无法通过启动屏幕的上下文中调用应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在applicationDidEnterBackground时保存UITableView属性,并在iOS中将其加载回applicationDidBecomeActive - Save UITableView property when applicationDidEnterBackground and load back it applicationDidBecomeActive in iOS iOS applicationDidBecomeActive:在didfinishlaunchingwithoptions之后未调用:已调用 - iOS applicationDidBecomeActive: not called after didfinishlaunchingwithoptions: called viewDidAppear 在 applicationDidEnterBackground 之后调用? - viewDidAppear called after applicationDidEnterBackground? applicationDidBecomeActive 何时被调用? - When is applicationDidBecomeActive called? 是否总是在applicationDidEnterBackground之后调用applicationWillEnterForeground? - Is applicationWillEnterForeground always called after applicationDidEnterBackground? 在&#39;applicationDidBecomeActive&#39;之后调用什么方法? - What method is called after 'applicationDidBecomeActive'? 在iOS 10中多次调用applicationDidBecomeActive - applicationDidBecomeActive called multiple times in iOS 10 何时针对requestAccessToEntityType调用applicationDidBecomeActive? - When does applicationDidBecomeActive get called with respect to requestAccessToEntityType? viewWillLayoutSubviews在applicationDidEnterBackground通知后调用 - viewWillLayoutSubviews getting called after applicationDidEnterBackground notification 在iOS上,如何调用applicationDidBecomeActive,loadView和viewDidLoad? - On iOS, how do applicationDidBecomeActive, loadView, and viewDidLoad get called?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM