I am using the latest version of FaceBook App Events plugin in Flutter with the latest version of Flutter as well. On click event, I am calling the logEvent method like this:
facebookAppEvents.logEvent(
name: 'Link Clicked',
parameters: {'url': request.url},
);
where the facebookAppEvents defined and initialized in the class itself:
static final facebookAppEvents = FacebookAppEvents();
Advertiser tracking is working with no problem using the following statement:
facebookAppEvents.setAdvertiserTracking(enabled: true);
However, I am getting an exception when calling the logEvent method. The exception is:
E/MethodChannel#flutter.oddbit.id/facebook_app_events(26467): Failed to handle method call
E/MethodChannel#flutter.oddbit.id/facebook_app_events(26467): kotlin.UninitializedPropertyAccessException: lateinit property appEventsLogger has not been initialized
Flutter doctor has no problem nor warning. I tried to clean and rebuild the project but still getting the same exception. All the tests I did are on Android only. Any way to fix this?
I added ApplicationId meta data only because the flutter plugin documentation said so and got the error. But then solved it by adding ClientToken to AndroidManifest.xml ( you should add facebook_client_token as a string resource as well )
AndroidManifest.xml
<application android:label="@string/app_name" ...>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
</application>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="facebook_app_id">123123</string>
<string name="facebook_client_token">456456</string>
</resources>
More Info: https://developers.facebook.com/docs/app-events/getting-started-app-events-android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With