OGeek|极客世界-中国程序员成长平台

标题: ios - 由于进入监控区域,应用启动后使用 Flurry 记录事件 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:59
标题: ios - 由于进入监控区域,应用启动后使用 Flurry 记录事件

场景如下。我有一个 iOS 应用程序,它使用 CLLocationManager 的区域监控功能在输入预定义的地理区域时通知应用程序。区域监控的工作方式,可以通知应用程序用户进入区域,即使应用程序之前已终止。基本上,操作系统将在输入区域时启动应用程序(不将其置于前台),并让应用程序有机会响应输入的区域。

我想要做的是在输入区域时使用 Flurry 记录一个事件。目前,它似乎不起作用,因为即使在几天之后,事件也没有出现在 Flurry 中。我应该注意,我已经测试了 i) 在用户正常启动应用程序时 Flurry 事件日志记录在其他方面工作正常,并且 ii) 我的应用程序确实是接收区域进入和退出事件(每次进入或退出区域时我使用本地通知)。

我怀疑它与应用程序委托(delegate)生命周期有关,这与应用程序因进入区域而启动的时间与应用程序因用户启动它而启动的时间不同有关。我的第一个怀疑是在后台启动应用程序时没有调用 application:didFinishLaunchingWithOptions: 。因为我对 [Flurry startSession"my_key"] 的调用是在 application:didFinishLaunchingWithOptions: 方法中,所以这可以解释一些事情。但是,startMonitoringForRegion:desiredAccuracy: 的 Apple 文档表明 application:didFinishLaunchingWithOptions: 实际上被称为:

If you begin monitoring a region and your application is subsequently terminated, the system automatically relaunches it into the background if the region boundary is crossed. In such a case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location-related event.

虽然我使用的是 startMonitoringForRegion: 而不是 startMonitoringForRegion:desiredAccuracy:(已弃用),但我假设两者都调用 application:didFinishLaunchingWithOptions:。然后我阅读了 Flurry 文档中关于 startSession: 的注释(强调我的):

This method serves as the entry point to Flurry Analytics collection. It must be called in the scope of applicationDidFinishLaunching. The session will continue for the period the app is in the foreground until your app is backgrounded for the time specified in setSessionContinueSeconds:. If the app is resumed in that period the session will continue, otherwise a new session will begin. Note: If testing on a simulator, please be sure to send App to background via home button. Flurry depends on the iOS lifecycle to be complete for full reporting.

所以,我怀疑即使我在真实设备上进行测试,该应用程序也永远不会“发送到后台”,因为它启动时从未进入前台。谁能澄清这是否是我记录的事件从未出现的原因,或者是否有其他原因?而且,有解决方法吗?



Best Answer-推荐答案


所以我联系了 Flurry 支持,这是我收到的回复:

So, at present its not possible to record / log events while the app is in the background.

Our engineering team is working on a solution to this and this should be available in one of the future versions of our SDK, in probably a months time.

所以我想我们会拭目以待。

关于ios - 由于进入监控区域,应用启动后使用 Flurry 记录事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620675/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4