简体   繁体   English

启动应用后,由于进入了受监视区域,因此使用Flurry记录了事件

[英]Recording events with Flurry after app was launched due to a monitored region being entered

The scenario is as follows. 情况如下。 I have an iOS app that uses the CLLocationManager's region monitoring feature to notify the app when a predefined geographic region is entered. 我有一个iOS应用程序,该应用程序使用CLLocationManager的区域监视功能在输入预定义的地理区域时通知该应用程序。 The way region monitoring works, the app can be notified of a user entering a region, even if the app was previously terminated. 区域监视的工作方式是,即使应用程序先前已终止,也可以将用户进入区域的通知通知给该应用程序。 Basically, the operating system will launch the app (without bringing it to the foreground), when the region is entered, and gives the app a chance to respond to the region being entered. 基本上,操作系统会在进入区域时启动应用程序(而不将其置于前台),并使应用程序有机会对输入的区域做出响应。

What I am trying to do is log an event using Flurry when the region is entered. 我想做的是在输入区域时使用Flurry记录事件。 Currently, it does not seem to be working, as the events are not showing up in Flurry, even after several days. 目前,它似乎不起作用,因为事件甚至在几天后都没有出现在Flurry中。 I should note that I have tested both i) that Flurry event logging is otherwise working OK when the app is launched as normal by the user and ii) that my app is indeed receiving the region entered and exited events (I use local notifications each time the region is entered or exited). 我应该注意,我已经测试了以下两项: i)当用户正常启动应用程序时Flurry事件日志正常运行;以及ii)我的应用程序确实在接收进入和退出的区域事件(我每次都使用本地通知)进入或退出该区域)。

My suspicion is that it has something to do with the application delegate lifecycle differing when the app is launched as a result of entering a region versus when the app is launched as a result of the user starting it. 我的怀疑是,它与应用程序委托生命周期有关,这与由于进入区域而启动应用程序与由于用户启动应用程序而导致启动应用程序不同。 My first suspicion was that application:didFinishLaunchingWithOptions: was not called when the app was launched in the background. 我的第一个怀疑是在后台启动应用程序时未调用application:didFinishLaunchingWithOptions: Because my call to [Flurry startSession:@"my_key"] is in the application:didFinishLaunchingWithOptions: method, this would have explained things. 因为我对[Flurry startSession:@"my_key"]调用是在application:didFinishLaunchingWithOptions:方法中,所以这已经可以解释了。 However, the Apple documentation for startMonitoringForRegion:desiredAccuracy: suggests that application:didFinishLaunchingWithOptions: is in fact called: 但是,Apple文档startMonitoringForRegion:desiredAccuracy:建议将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. 在这种情况下,传递给应用程序委托的application:didFinishLaunchingWithOptions:方法的选项字典包含键UIApplicationLaunchOptionsLocationKey,以指示由于位置相关事件而启动了您的应用程序。

Although I'm using startMonitoringForRegion: and not startMonitoringForRegion:desiredAccuracy: (deprecated), I'm assuming that both call application:didFinishLaunchingWithOptions: . 尽管我使用的是startMonitoringForRegion:而不是startMonitoringForRegion:desiredAccuracy:不建议使用),但我假设两者都调用application:didFinishLaunchingWithOptions: startMonitoringForRegion:desiredAccuracy: I then read a note in the Flurry documentation about startSession: (emphasis mine): 然后,我在Flurry文档中阅读了有关startSession:的注释startSession:重点是我的):

This method serves as the entry point to Flurry Analytics collection. 此方法用作Flurry Analytics集合的入口点。 It must be called in the scope of applicationDidFinishLaunching. 必须在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:. 在应用程序处于前台状态期间,会话将继续进行,直到您的应用程序在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. 注意: 如果要在模拟器上进行测试,请确保通过“主页”按钮将App发送到后台。 Flurry depends on the iOS lifecycle to be complete for full reporting. Flurry依赖于iOS生命周期来完成完整的报告。

So, my suspicion is that even though I am testing on a real device, the app never gets "sent to the background" because when it launches it never enters the foreground to begin with. 因此,我的怀疑是,即使我在真实的设备上进行测试,该应用也永远不会“发送到后台”,因为它在启动时永远不会进入前台。 Can anyone clarify whether this is the reason for my logged events never showing up, or whether there is perhaps some other reason? 谁能说明这是我的记录事件从未出现的原因,还是可能还有其他原因? And, is there a workaround for this? 而且,有没有解决方法?

So I contacted Flurry support and this is what I heard back: 所以我联系了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. 我们的工程团队正在努力解决此问题,并且可能会在一个月后的将来版本的SDK中提供该解决方案。

So I guess we'll wait and see. 所以我想我们会拭目以待。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM