振幅未记录 "applicationWillTerminate" iOS 中写入的事件

Aplitude not logging the event written in "applicationWillTerminate" iOS

我已经在 ios 项目中安装了 amplitude。我能够将事件发送到振幅。我能够在仪表板中看到事件。

但我无法在仪表板中看到应用程序关闭事件。

请在下面找到附加代码。

func applicationWillTerminate(_ application: UIApplication) {
    Amplitude.instance()?.logEvent("APP_CLOSED")
}

来自以下苹果文档, https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate

Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.

我猜测记录此特定事件的过程需要超过 5 秒才能执行,因此被强制终止。