Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 792
Manuel Avatar asked Jun 24 '18 00:06

Manuel


People also ask

What is Facebook SDK for iOS?

What is the Facebook SDK? The Facebook SDK is what allows mobile app developers to integrate Facebook within a mobile app. SDK stands for software development kit, and it allows for a website or app to integrate with Facebook seamlessly.


1 Answers

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

like image 164
CAHbl463 Avatar answered Oct 02 '22 19:10

CAHbl463