From 1af789e6eef09a9110f440b4b0e6c35c24874813 Mon Sep 17 00:00:00 2001 From: Dennis Alund Date: Wed, 25 Feb 2026 13:43:07 +0800 Subject: [PATCH 1/2] fix: override stale Graph API version and expose setGraphApiVersion() Facebook SDK v18.x ships with an outdated default Graph API version that Meta has already removed (iOS: v17.0 removed Sep 2025, Android: v16.0 removed May 2025). There is no SDK v19.x yet; this is a known upstream issue with no Meta-provided fix. This commit applies two changes to resolve #474: - Override the default to v24.0 at plugin initialization on both iOS (Settings.shared.graphAPIVersion) and Android (FacebookSdk.setGraphApiVersion). This is transparent and requires no app-level changes. - Expose setGraphApiVersion(String version) in the Flutter API for apps that need to target a specific version. Must be called before activateApp() to take effect. Upstream issues: https://github.com/facebook/facebook-ios-sdk/issues/2610 https://github.com/facebook/facebook-android-sdk/issues/1308 Co-Authored-By: Claude Sonnet 4.6 --- .../FacebookAppEventsPlugin.kt | 18 ++++++++++++++++++ .../FacebookAppEventsPlugin.swift | 16 ++++++++++++++++ lib/facebook_app_events.dart | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt b/android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt index f61cc1f0..1ca1c8b9 100644 --- a/android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt +++ b/android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt @@ -38,6 +38,13 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler { application = flutterPluginBinding.applicationContext.applicationContext as? Application appEventsLogger = AppEventsLogger.newLogger(flutterPluginBinding.applicationContext) anonymousId = AppEventsLogger.getAnonymousAppDeviceGUID(flutterPluginBinding.applicationContext) + + // Override the Graph API version because Facebook Android SDK v18.x still defaults to v16.0, + // which was removed by Meta on May 14, 2025. This is a known upstream issue: + // https://github.com/facebook/facebook-android-sdk/issues/1308 + // Note: the SDK emits a Log.w in release builds when this is called, but the version is + // still applied. This is intentional and correct behavior for a plugin. + FacebookSdk.setGraphApiVersion("v24.0") } override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { @@ -61,6 +68,7 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler { "getAnonymousId" -> handleGetAnonymousId(call, result) "logPurchase" -> handlePurchased(call, result) "setAdvertiserTracking" -> handleSetAdvertiserTracking(call, result) + "setGraphApiVersion" -> handleSetGraphApiVersion(call, result) else -> result.notImplemented() } @@ -123,6 +131,16 @@ class FacebookAppEventsPlugin: FlutterPlugin, MethodCallHandler { result.success(anonymousId) } + private fun handleSetGraphApiVersion(call: MethodCall, result: Result) { + val version = call.arguments as? String + if (version == null) { + result.error("INVALID_ARGUMENT", "Graph API version string is required", null) + return + } + FacebookSdk.setGraphApiVersion(version) + result.success(null) + } + private fun handleSetAdvertiserTracking(call: MethodCall, result: Result) { val enabled = call.argument("enabled") ?: false val collectId = call.argument("collectId") ?: true diff --git a/ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift b/ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift index 906425da..b7e0b586 100644 --- a/ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift +++ b/ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift @@ -16,6 +16,11 @@ public class FacebookAppEventsPlugin: NSObject, FlutterPlugin { // "Removal of Auto Initialization of SDK" section ApplicationDelegate.shared.initializeSDK() + // Override the Graph API version because Facebook iOS SDK v18.x still defaults to v17.0, + // which was removed by Meta on September 12, 2025. This is a known upstream issue: + // https://github.com/facebook/facebook-ios-sdk/issues/2610 + Settings.shared.graphAPIVersion = "v24.0" + registrar.addMethodCallDelegate(instance, channel: channel) registrar.addApplicationDelegate(instance) } @@ -60,6 +65,8 @@ public class FacebookAppEventsPlugin: NSObject, FlutterPlugin { handleHandleGetAnonymousId(call, result: result) case "setAdvertiserTracking": handleSetAdvertiserTracking(call, result: result) + case "setGraphApiVersion": + handleSetGraphApiVersion(call, result: result) default: result(FlutterMethodNotImplemented) } @@ -199,6 +206,15 @@ public class FacebookAppEventsPlugin: NSObject, FlutterPlugin { result(nil) } + private func handleSetGraphApiVersion(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + guard let version = call.arguments as? String else { + result(FlutterError(code: "INVALID_ARGUMENT", message: "Graph API version string is required", details: nil)) + return + } + Settings.shared.graphAPIVersion = version + result(nil) + } + private func handleSetAdvertiserTracking(_ call: FlutterMethodCall, result: @escaping FlutterResult) { let arguments = call.arguments as? [String: Any] ?? [:] let enabled = arguments["enabled"] as? Bool ?? false diff --git a/lib/facebook_app_events.dart b/lib/facebook_app_events.dart index d8973b38..94a68c1e 100644 --- a/lib/facebook_app_events.dart +++ b/lib/facebook_app_events.dart @@ -501,6 +501,23 @@ class FacebookAppEvents { ); } + /// Overrides the Graph API version used by the Facebook SDK. + /// + /// The plugin sets a default Graph API version at initialization because the + /// Facebook SDK v18.x ships with an outdated default that has been removed by + /// Meta. Call this method **before** [activateApp] if you need a specific version. + /// + /// The [version] string must be in the form `"vX.Y"` (e.g. `"v24.0"`). + /// Refer to Meta's [Graph API changelog](https://developers.facebook.com/docs/graph-api/changelog/) + /// for currently supported versions. + /// + /// See documentation: + /// - [iOS Settings](https://developers.facebook.com/docs/reference/iossdk/current/FBSDKCoreKit/classes/settings.html) + /// - [Android FacebookSdk](https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/FacebookSdk.html) + Future setGraphApiVersion(String version) { + return _channel.invokeMethod('setGraphApiVersion', version); + } + // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // From 58daadf54fe17c76a5c1237f49caee069ab2117a Mon Sep 17 00:00:00 2001 From: Dennis Alund Date: Wed, 25 Feb 2026 13:43:16 +0800 Subject: [PATCH 2/2] docs: document Graph API version override and setGraphApiVersion() Add a "Graph API Version" section to the Known Limitations chapter explaining why the plugin overrides the Facebook SDK default and how to use setGraphApiVersion() for apps that need version control. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index b455d09a..88bc19a8 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,33 @@ with your other plugins or dependencies. ## Known Limitations +### Graph API Version + +The Facebook SDK v18.x ships with an outdated default Graph API version that Meta has already removed: + +| Platform | SDK default | Removed by Meta | +|---|---|---| +| iOS SDK v18.x | `v17.0` | September 12, 2025 | +| Android SDK v18.x | `v16.0` | May 14, 2025 | + +This plugin works around the issue by overriding the Graph API version to `v24.0` at initialization. This is transparent and requires no configuration for the vast majority of apps. + +If you need to target a specific Graph API version (e.g. to pin to the same version as your backend), call `setGraphApiVersion` **before** `activateApp`: + +```dart +final facebookAppEvents = FacebookAppEvents(); + +// Override the Graph API version (optional — plugin defaults to v24.0) +await facebookAppEvents.setGraphApiVersion('v24.0'); + +// Then activate the app as usual +await facebookAppEvents.activateApp(); +``` + +Refer to Meta's [Graph API changelog](https://developers.facebook.com/docs/graph-api/changelog/) for currently active versions. + +This is a plugin-specific workaround for a [known upstream issue in the iOS SDK](https://github.com/facebook/facebook-ios-sdk/issues/2610) and [Android SDK](https://github.com/facebook/facebook-android-sdk/issues/1308). When Meta releases SDK v19.x with a corrected default, this override will become a no-op and the method can safely be removed from your code. + ### Facebook Event Manager "Please Upgrade SDK" Warning When setting up codeless events in Facebook Event Manager, you may encounter a warning message stating: