iosswiftfacebook-ios-sdkfbsdk

Add Facebook SDK `activateApp` to `applicationDidBecomeActive`?


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?


Solution

  • 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.