FB.ActivateApp
Updated: Mar 1, 2018
By logging app activation events, you can observe how frequently users activate your app, how much time they spend using it, and view other demographic information through Facebook Analytics for Apps.
Sending app activation events are also necessary to measure installs driven by App Ads, whose documentation you should consult for details.
Note: Does nothing on desktop apps at this time.
Parameters
public static void ActivateApp()
Example
Send an app activation event to Facebook when your app is activated.
FB.ActivateApp();
Best Practices
Calling ActivateApp notifies Facebook that a session has begun in your application. You should be calling ActivateApp both on launch and each application resume to ensure you are correctly measuring sessions.
The SDK needs to be initalized first with
FB.Init before you can call FB.ActivateApp.
Consider utilizing Unity's Awake function from MonoBehavior to cover App Launches.
void Awake ()
{
if (FB.IsInitialized) {
FB.ActivateApp();
} else {
//Handle FB.Init
FB.Init( () => {
FB.ActivateApp();
});
}
}
Consider utilizing Unity's OnApplicationPause function from MonoBehavior to cover App Resumes.
// Unity will call OnApplicationPause(false) when an app is resumed
// from the background
void OnApplicationPause (bool pauseStatus)
{
// Check the pauseStatus to see if we are in the foreground
// or background
if (!pauseStatus) {
//app resume
if (FB.IsInitialized) {
FB.ActivateApp();
} else {
//Handle FB.Init
FB.Init( () => {
FB.ActivateApp();
});
}
}
}