Add Facebook SDK `activateApp` to `applicationDidBecomeActive`?
Asked Answered
W

1

7

Is it necessary to add FBSDKAppEvents.activateApp() to applicationDidBecomeActive when FacebookAutoLogAppEventsEnabled is not set to false?

According to FBSDKAppEvents.h it is not necessary:

Notifies the events system that the app has launched and, when appropriate, logs an "activated app" event. This function is called automatically from FBSDKApplicationDelegate applicationDidBecomeActive, unless one overrides 'FacebookAutoLogAppEventsEnabled' key to false in the project info plist file. In case 'FacebookAutoLogAppEventsEnabled' is set to false, then it should typically be placed in the app delegates' applicationDidBecomeActive: method.

This is confirmed by the FB docs where adding activateApp is under "Manual Event Logging":

The process described here for manual event logging with the SDK is provided so that you have the option of controlling when app events are logged. We recommend that you do not disable automatic logging because it may impact how data is collected for your app.

However, in the Swift Reference it says:

Logging app activations as an app event enables most other functionality and should be the first thing that you add to your app.

So should it be added or is it called automatically for Swift apps?

Whalen answered 24/6, 2018 at 0:24 Comment(2)
The issue is a specific area and more related to the business logic of Facebook itself. Please look for the answer to your question or ask it better here: developers.facebook.com/supportSplenius
@CAHbl463 I always wondered about this statement. Can you refer to a specific SO guideline? After all, why is there a facebook-ios-sdk tag if questions regarding the product should not be asked here? At some point a product becomes so popular that using it becomes an integral part of software development, and I think that is what SO is all about.Whalen
S
3
  • FacebookAutoLogAppEventsEnabled - Automatically collects application events.

  • FBSDKAppEvents.activateApp() - Manual sending of an application event. It guarantees that the event will be forcibly collected, regardless of external factors, of course if SDK initialized with the correct AppId.

Based on the FB docs discussion of FBSDKAppEvents.activateApp():

activateApp will not log an event on every app launch, since launches happen every time the app is backgrounded and then foregrounded.  "activated app" events will be logged when the app has not been active for more than 60 seconds.

Which hints that his internal logic is smart and does not depend on how, where and with what frequency he is called.

My opinion, if it is important for you, is to collect application events for analytics. I recommend calling FBSDKAppEvents.activateApp() method in applicationDidBecomeActive manually, in parallel and independently of the automatic FacebookAutoLogAppEventsEnabled. This will not be a warning, error or violation of the guideline.

If I have given too few arguments to confirm my recommendation. Then, if necessary, I will describe in expanded form what I was guided by and how I analysed to adopt such an opinion.

Splenius answered 10/9, 2019 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.