Hi,
I’m building an extension to log events with Facebook Analytics.
According to the documentation, we need to call some methods when the app is created:
package com.example.hellofacebook;
import android.app.Application;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
public class HelloFacebookSampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
}
Is there a way to achieve the same in an extension?
I’ve tried this in my extension:
@SimpleFunction(description = "Initialize SDK")
public void Initialize(String facebookAppId) {
FacebookSdk.setApplicationId(facebookAppId);
FacebookSdk.sdkInitialize(this.container.$context().getApplicationContext());
AppEventsLogger.activateApp(this.container.$context().getApplication());
this.logger = AppEventsLogger.newLogger(this.container.$context());
}
I call it the Initialize block of the screen I want to log events but it doesn’t seem to work. I got this warning in logcat: “W/com.facebook.appevents.internal.ActivityLifecycleTracker: Unexpected activity pause without a matching activity resume. Logging data may be incorrect. Make sure you call activateApp from your Application’s onCreate method”
Thank you for your help!