# Changelog

## 2.0.1

### Fixed

- **iOS: `openSupport()` / `trackEvent()` / `setUserProperties()` / `setTicketProperties()`
  called immediately after `initialize()` resolved could silently fail.** The
  native SDK's `Freshdesk.initialize(with:)` has no completion callback,
  `async` variant, notification, or published readiness property — confirmed
  by inspecting the vendored xcframework's own public and private
  `.swiftinterface` files. It does its own async internal loading after
  `initialize()` returns, and any call made before that finishes is silently
  queued/dropped by the native SDK itself, logging `"Tasks will be executed
  once the SDK is loaded"`. The wrapper's JS-bridge `initialize()` was
  resolving instantly on the native call returning, with no wait for real
  readiness. `initialize()` on iOS now resolves only after a fixed 2-second
  settle delay past the native call returning — mirroring the same class of
  workaround Android's `FreshdeskInitCoordinator` already uses for the
  equivalent problem on that platform. This is a heuristic (no real signal
  exists to poll), documented in `PLATFORM_DIFFERENCES.md`. **Practical
  effect: `initialize()` on iOS now always takes at least ~2 seconds**, even
  on a fast network. The native-direct `initializeSDK` entry point (used so
  push token registration isn't blocked on JS) deliberately does not get this
  delay, to preserve its own timing guarantee.

### Changed

- `trackEvent`/`setUserProperties`/`setTicketProperties` no longer
  `JSON.stringify()` their properties argument across the bridge — the
  codegen `Spec` now declares them as `Object`, matching `initialize()`'s and
  `runDiagnostics()`'s existing convention. Public JS signatures are
  unchanged (still take a plain object) — **non-breaking**. Removes a
  round-trip encode/decode that was pure overhead and an extra place either
  side of the bridge could disagree about shape. `getUser()`'s JSON-string
  return value is intentionally **not** migrated — its shape mirrors
  whatever the native SDK's live user object serializes to, which isn't safe
  to converge without live-account verification.
- Collapsed host normalization to the single JS source of truth
  (`src/utils/normalizeHost.ts`). Both platforms' JS-bridge `initialize()`
  entry points no longer re-normalize (the JS layer already did it); each
  platform's separate **native-direct** init entry point (no JS layer in
  front of it) still normalizes its own host.
- Android: `compileSdkVersion`/`targetSdkVersion` fallback (when a consumer
  app doesn't set its own `ext` values) is now **35**, not 36 — matching the
  level `sample_app` actually builds and tests against. Still overridable via
  the consumer's own root `ext` block.

### Added

- `FreshdeskErrorCode` enum exported from the package root — all 16 native
  reject codes, each documented with which platform(s) can emit it. Re-export
  of the existing `FreshdeskEventName` type alongside it, so consumers can
  match on enum members instead of hand-typed string literals.
- `PLATFORM_DIFFERENCES.md` — documents every method whose *runtime
  behavior* (not just its error surface) differs by platform because the
  underlying native SDKs don't expose the same capability:
  `resetUser()` (iOS has no failure callback), `enableDebugLogs()` (Android
  only takes effect if set at `initialize()` time), `getUnreadCount()`
  (Android is a cached broadcast value, iOS is live), `trackEvent()` (Android
  passes typed values, iOS coerces every value to a string), and the new
  iOS `initialize()` settle delay above.
- `FreshdeskInitCoordinator` (Android, internal) — isolates the
  reflection-based native-readiness probe and the two previously-magic
  timing constants (`READINESS_RECHECK_DELAY_MS` = 5s,
  `INIT_HARD_TIMEOUT_MS` = 20s) out of `FreshdeskModule.kt`, with dedicated
  JVM unit tests. No behavior change — a maintainability/testability
  refactor.
- `scripts/verify-native-builds.sh` (`npm run verify:native` at the repo
  root) — runs the same build legs as `build-matrix.yml` locally (Android
  old/new arch, iOS old/new arch, JS tsc + jest). Documented as the interim
  pre-merge gate while this org's GitHub Actions network policy blocks
  `actions/checkout` on hosted runners.

### Notes

- Investigated moving the vendored `FreshdeskSDK.xcframework` to a
  checksummed `prepare_command` download instead of committing the binary.
  Decided against it: it would make every consumer's `pod install` depend on
  live GitHub reachability, which is not something this project can
  guarantee. Documented the reasoning in the podspec; Git LFS is the
  better answer if binary size growth becomes a real problem later.

## 2.0.0

### Breaking

- Minimum React Native is now **0.75** (`peerDependencies.react-native` is
  `>=0.75.0`, was `*`). This matches the de-facto floor 1.4.x already had — it
  was built at RN 0.75.4 and its SPM iOS path required RN >= 0.75. On RN < 0.75,
  stay on `~1.4.3`.
- iOS integration no longer requires `use_frameworks!` / `cocoapods-spm`. The
  native SDK is consumed only as a vendored `FreshdeskSDK.xcframework`. The
  `spm_dependency` / `cocoapods-spm` / hand-rolled Folly flags / `NewArch`
  subspec / `FRESHDESK_IOS_USE_VENDORED` env gate are all removed from the
  podspec. See `MIGRATION.md` for the exact Podfile / Gemfile lines to delete.

### Added

- React Native **New Architecture (TurboModule)** support. The module is now
  backward-compatible: a TurboModule when the New Architecture is enabled, the
  classic bridge module (`NativeModules`) otherwise. The runtime module name is
  unchanged (`FreshdeskReactNative`).
- `runDiagnostics()` reports `architecture` (`'old'` / `'new'`) and `turboModule`
  (boolean) as optional fields.
- `codegenConfig` in `package.json` is now backed by real generated code
  (`src/NativeFreshdesk.ts` is a codegen spec using `TurboModuleRegistry.get`).
- iOS podspec adds `s.static_framework = true`, a guarded
  `install_modules_dependencies(s)` (which auto-discovers this library's
  `codegenConfig` on RN >= 0.75), and `-D RCT_NEW_ARCH_ENABLED` in
  `OTHER_SWIFT_FLAGS` when `ENV['RCT_NEW_ARCH_ENABLED'] == '1'`.

### Fixed

- New Architecture **Android** builds failed with a `cmake … default-app-setup`
  error because a `codegenConfig` was published with no backing spec. New
  Architecture Android now builds; Old Architecture is unchanged.
- **Expo** apps failed to compile with `no such module 'Expo'` due to the forced
  dynamic-framework linkage. Removing `use_frameworks!` + the Freshdesk SPM lines
  and running `npx expo prebuild --clean` fixes it.

### Changed (internal, no JS impact)

- The Android `getConstants()` no longer returns the `EVENT_UNREAD_COUNT` /
  `EVENT_USER_STATE` values. They were never read from JavaScript; event name
  constants remain available from `FreshdeskEvents`.

### Unchanged

- Public JavaScript API, all exported names / signatures, and all exported
  TypeScript types.

### React Native version support

Supported range is **RN >= 0.75** (`peerDependencies`). `sample_app` and the
codegen verification pin 0.75.4; the CI build matrix's arch × platform legs are
the gate. RN < 0.75 is not supported by 2.0.0 — stay on `~1.4.3`.

## 1.4.3

- Docs-only release. See git history for details.
