Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CI (`.github/workflows/build-verify.yml`) fails on unformatted Dart (`dart forma

`example/integration_test/` runs the plugin inside the example app against the real Facebook SDK, on an Android emulator and an iOS simulator in CI. It is the only place the Kotlin and Swift handlers execute (the tests in `test/` mock the method channel), so a change to native behavior should come with a test there. Tests in that folder share one app process and run in file order.

## Documentation split

`README.md` is a quick start only: requirements, setup, the minimal consent and metadata configuration, the error-code table, and a troubleshooting table of links. Explanations, platform differences in depth, and troubleshooting live in the guides on the Oddbit website (https://oddbit.id/en/projects/facebook-app-events/guides, source in the `oddbit-website` repo under `data/{en,sv,id}/guides.json`). When a change needs more than a line or two of explanation, add or update a guide there and link it from the README through an `oddb.it/fbae-guide-*` short link, instead of growing the README.

## Plugin architecture

This plugin exposes Meta's Facebook App Events SDK to Flutter with an explicit 1:1 mapping between the Dart API and the native handlers. When adding, renaming, or modifying a method, keep the three layers in sync:
Expand All @@ -32,7 +36,7 @@ The plugin follows the **major** version of the Facebook SDK (currently v19.x).

## Known platform divergence

- `clearUserDataForType`: functional on iOS; no-op on Android (the Android `AppEventsLogger` has no per-field clear). Documented in the Dart dartdoc and README "Known Limitations".
- `clearUserDataForType`: functional on iOS; no-op on Android (the Android `AppEventsLogger` has no per-field clear). Documented in the Dart dartdoc and README "Platform notes".
- Deferred SDK initialization (`FacebookAutoInitEnabled` on iOS, `com.facebook.sdk.AutoInitEnabled` on Android, `initializeSdk()` in Dart): on iOS the SDK is fully unconfigured until `initializeSdk()`, so the Swift handler gates every method call except `initializeSdk`/`setGraphApiVersion` (and the URL forwarders) behind a `isSdkInitialized` flag and returns `FlutterError(sdk_not_initialized)`; adding a new handler must keep it behind that gate unless its SDK call is verified safe pre-configuration. On Android `AutoInitEnabled=false` still runs `sdkInitialize`, so there is no deferred-init gate and `initializeSdk` maps to `FacebookSdk.fullyInitialize()` — never `setAutoInitEnabled(true)`, which persists and overrides the manifest. If the Android SDK is not initialized at all (`FacebookInitProvider` swallows a failed start, or the app removed the provider), `onMethodCall` converts the SDK's `FacebookSdkNotInitializedException` to the same `sdk_not_initialized` code, and `initializeSdk` is the only place the plugin calls `sdkInitialize` (failing with `sdk_initialization_failed`); never initialize implicitly, since the app may be holding the SDK back for consent. For the same reason nothing in `onAttachedToEngine` may throw, and the `AppEventsLogger` is created lazily.
- `setUserData` uses merge semantics on both platforms: only fields present in the call are updated. The iOS handler deliberately skips absent keys because passing nil to the native setter would *clear* the field on iOS (Android ignores nulls).
- Graph API version override: plugin forces `v24.0` at init on both platforms. The Android SDK still defaults to the removed `v16.0` in v19.0.0 (`ServerProtocol.getDefaultAPIVersion`); the iOS SDK has defaulted to `v26.0` since 18.1.1, but the pin is kept on both for consistent Graph behavior. Revisit when the Android SDK ships a corrected default.
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 0.34.0

- **Fix (iOS): `logPushNotificationOpen` crashed the app when `fb_push_payload` was a JSON string.** That is how Firebase Cloud Messaging delivers the entry, and it is the form the Android SDK expects, but the iOS SDK subscripts it as a dictionary without checking the type. The iOS handler now parses a string entry, stringifies a numeric `campaign`, and drops an entry it cannot bring into shape. The Android handler does the reverse and serializes a map-shaped entry to JSON, which the Android SDK used to ignore. Android also no longer fails with `INVALID_ARGUMENT` on payload values a `Bundle` cannot hold, such as lists; the SDK only reads `fb_push_payload`, so those values are left out.
- **Fix (Android): a Facebook SDK that failed to start no longer surfaces as `lateinit property appEventsLogger has not been initialized`** (fixes [#516](https://github.com/oddbit/flutter_facebook_app_events/issues/516)). The SDK swallows its own failed start, typically a missing app id or client token, and the plugin was left half attached. Calls that need the SDK now fail with `sdk_not_initialized`, the code iOS already uses. `initializeSdk()` runs the SDK's initialization again and, if it still fails, throws `sdk_initialization_failed` with the SDK's own reason instead of reporting success. The plugin never initializes the SDK by itself, so an app that removed the SDK's init provider to wait for consent is not overridden.
- **Add `FacebookAppEventsException` and `FacebookAppEventsErrorCode`.** Errors reported by the native handlers are now thrown as `FacebookAppEventsException`, whose `errorCode` is an enum: `invalidArgument`, `sdkNotInitialized`, `sdkInitializationFailed`, `missingContext`, `missingApplication` or `unknown`. The exception extends `PlatformException` and `code` still holds the same string as before, so existing `on PlatformException` handlers and string comparisons keep working. Two things do change: the exception's runtime type and its `toString()` text, so crash reporters that group by exception type will file these errors under the new name. New values can be added to the enum in later releases; keep a wildcard branch when you `switch` over it.
- **Behavior change: currency codes are validated the same way on both platforms.** `logPurchase` and `logProductItem` now accept ISO 4217 codes in any letter case on Android and iOS, and an unknown code throws `invalidArgument` on both. Until now Android rejected lower-case and unknown codes while iOS passed any string to the SDK. On iOS this means a call with a non-ISO currency, which used to be logged, now throws.
- **Document the Xcode 26.4 minimum.** Since 0.32.0 the Facebook iOS SDK v19 ships Swift interfaces that older compilers cannot read, and the build fails inside the SDK with "Consecutive statements on a line must be separated by ';'". Confirmed on CI: Xcode 26.3 fails, Xcode 26.4.1 builds. The README lists the requirement, and CI now builds on Xcode 26.4 as well as the newest version.
- **The README is now a quick start.** Requirements, setup, the minimal consent and event-metadata configuration, the error codes and a troubleshooting table stay. The background, the platform differences in depth and the troubleshooting moved to the [guides on oddbit.id](https://oddb.it/fbae-guides), including three new ones: [holding the Facebook SDK back until consent](https://oddb.it/fbae-guide-consent), [what Facebook SDK v19 attaches to your events](https://oddb.it/fbae-guide-event-metadata) and [Facebook SDK `.swiftinterface` build errors](https://oddb.it/fbae-guide-xcode).
- **The native handlers are now tested against the real Facebook SDK.** `example/integration_test` runs the plugin inside the example app on an Android emulator and an iOS simulator in CI, including an Android build without a client token to cover an SDK that fails to start. Until now the Kotlin and Swift code was only compiled, never executed, before a release.
- The example app's Android project moves to AGP 9.3.1 and Gradle 9.5.0, which Flutter 3.50 requires, following the Flutter 3.50 app template (`android.builtInKotlin=false`, no `kotlin-android` in the app). The plugin's own Android build and its minimum Flutter version (3.41) are unchanged, and CI still builds it with AGP 8 on the Flutter floor.
- CI: Dart checks (`dart format`, `flutter analyze`, tests) run on the Flutter 3.41 floor as well as stable; a test guards the versions that a release must keep in step (pubspec, podspec, changelog, the Graph API pin and the Facebook SDK major); the publish job refuses a tag that differs from `pubspec.yaml`; the NDK install is retried; the Flutter SDK is no longer cached and pull request caches are deleted when the pull request closes.
- `CLAUDE.md` is replaced by `AGENTS.md`, which Claude Code and other coding agents read. IDE project files (`.idea/`, `*.iml`) are no longer tracked or published. The package description no longer mentions Facebook Analytics, which Meta retired in 2021.

## 0.33.0

- **Breaking: raise the minimum Flutter SDK to `>=3.41.0`** (was `>=3.38.0`). The iOS Swift package now depends on the local `FlutterFramework` package that the Flutter tool generates for Swift Package Manager builds, as Flutter's plugin-author migration guide requires (fixes [#514](https://github.com/oddbit/flutter_facebook_app_events/issues/514)). Flutter 3.41 is the first release that generates that package, and future Flutter versions will require the dependency. The Dart API and native behavior are unchanged. Apps on Flutter 3.38–3.40 keep resolving 0.32.x.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Also check the pinned Graph API version while preparing a release. The plugin ov

- `android/src/main/kotlin/id/oddbit/flutter/facebook_app_events/FacebookAppEventsPlugin.kt` — `FacebookSdk.setGraphApiVersion(...)`
- `ios/facebook_app_events/Sources/facebook_app_events/FacebookAppEventsPlugin.swift` — `Settings.shared.graphAPIVersion = ...`
- `README.md` — the "Graph API Version" section under Known Limitations
- `README.md` — the "Graph API version" entry under Platform notes

The deadline worth tracking is **not** a version's expiry date. Calls to an expired version are routed to the oldest version that is still usable ([Graph API versioning](https://oddb.it/fbae-graph-versioning)), so nothing breaks outright. What reaches app owners is Meta's deprecation notice, which sets a floor ("all versions prior to vXX will be removed") on Meta's own schedule, independent of any expiry. Compare the pin against [Meta's Graph API changelog](https://oddb.it/fbae-graph-changelog) at release time and bump it if the current latest has moved well past it.

Expand Down
Loading
Loading