我正在尝试在我的颤振项目中调用 Facebook 应用程序事件。我正在使用依赖facebook_app_events: ^0.12.0。元数据也被添加到清单文件中。
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
void callFBEvent() async {
try {
var i = await facebookAppEvents.getAnonymousId();
await facebookAppEvents.setAdvertiserTracking(enabled: true);
await facebookAppEvents.logEvent(
name: "User_Selection_Screen", parameters: {
"User_Selection": "User_Selection",
});
print("facebook event success User_Selection_Screen");
}catch(e){
print(e);
}
}
低于错误
kotlin.UninitializedPropertyAccessException: lateinit property anonymousId has not been initialized
at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.handleGetAnonymousId(FacebookAppEventsPlugin.kt:82)
at id.oddbit.flutter.facebook_app_events.FacebookAppEventsPlugin.onMethodCall(FacebookAppEventsPlugin.kt:55)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:822)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:336)
at android.os.Looper.loop(Looper.java:174)
at android.app.ActivityThread.main(ActivityThread.java:7386)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)