Skip to content

fix(native): iOS push payload crash, and currency/payload parity across platforms - #523

Merged
DennisAlund merged 1 commit into
mainfrom
fix/platform-parity
Nov 17, 2026
Merged

DennisAlund merged 1 commit into
mainfrom
fix/platform-parity

Conversation

@DennisAlund

@DennisAlund DennisAlund commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Stacked on #522 (this branch contains its commits); merge that first.

From the project analysis: places where the same Dart call behaved differently per platform. One of them is an app crash on iOS.

Currency codes (logPurchase, logProductItem)

Before After
Unknown code, e.g. "dollars" Android: INVALID_ARGUMENT. iOS: logged as is. INVALID_ARGUMENT on both
Lower case, e.g. "usd" Android: INVALID_ARGUMENT. iOS: logged as usd. Accepted on both, sent as USD

The Android SDK takes a java.util.Currency, so that handler must reject unknown codes. The iOS SDK takes any string, so the iOS handler now checks against the ISO 4217 list itself (Locale.Currency.isoCurrencies on iOS 16+, Locale.isoCurrencyCodes on iOS 15).

Behavior change on iOS: a call with a currency that is not an ISO 4217 code used to be logged and now throws FacebookAppEventsException (invalidArgument). Worth a line in the release notes.

Push payloads (logPushNotificationOpen)

iOS crash on a JSON-string fb_push_payload

Found while writing integration tests. The iOS SDK does this with the payload, without checking types (FBSDKAppEvents.m, v19.0.1):

NSDictionary *facebookPayload = payload[FBSDKAppEventsPushPayloadKey];
NSString *campaign = facebookPayload[FBSDKAppEventsPushPayloadCampaignKey];
if (campaign.length == 0) { ...

Firebase Cloud Messaging delivers data entries as strings, so fb_push_payload is normally a JSON string, which is also the form the Android SDK expects. Passing that on iOS subscripts an NSString and raises an Objective-C exception, which terminates the app. The same happens for a campaign that is not a string.

The iOS handler now parses a string entry into a dictionary, stringifies a numeric campaign, and drops an entry it cannot bring into shape (the SDK then ignores the notification).

Android ignored a map-shaped fb_push_payload

The Android SDK reads the entry with getString, so the nested map an APNs-style payload carries was silently ignored. The Android handler now serializes a map entry to JSON.

Android failed on unrelated list values

Android returned INVALID_ARGUMENT when the payload held a value a Bundle cannot store, such as a list, while iOS accepted the same payload. The SDK only reads fb_push_payload, so the handler now leaves unsupported values out instead of failing.

Verification

Kotlin and Swift are compile-checked by this PR's CI only. None of these changes has run on a device, and the iOS crash itself was found by reading the SDK source, not reproduced. The integration tests in the follow-up PR exercise all of them on an emulator and a simulator.

@DennisAlund DennisAlund changed the title fix(native): same currency and push payload handling on Android and iOS fix(native): iOS push payload crash, and currency/payload parity across platforms Nov 17, 2026
@DennisAlund

Copy link
Copy Markdown
Member Author

All commits of this PR reached main through #525, which was stacked on top of it. Merging this branch now would change nothing in main (checked with a trial merge). It still showed as open only because its branch carries one extra merge commit that #525's branch does not. Closing as merged via #525.

@DennisAlund DennisAlund reopened this Nov 17, 2026
@DennisAlund
DennisAlund merged commit a676d17 into main Nov 17, 2026
11 checks passed
@DennisAlund
DennisAlund deleted the fix/platform-parity branch November 17, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant