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
31 changes: 31 additions & 0 deletions repositories/d-sports-engage-native/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ Focused #1409 tests are `lib/__tests__/tier2-android.test.ts` (tokens, tile mani
PR #1425 adds `modules/expo-android-nfc/` and registers `plugins/withAndroidNfc.js` in `app.json`.
This is a separate link transport from [Apple Wallet passes](/repositories/d-sports-engage-native/feature-mapping#apple-wallet-passes).
It reuses the arena URL family of the [iOS App Clip](/repositories/d-sports-engage-native/architecture#app-clip-configuration).
The full iOS app reads the same URLs with [Core NFC](#ios-core-nfc-configuration).

`ExpoAndroidNfcModule.kt`, `DsportsNfcHceService.kt`, and `NdefUrlCodec.kt` live under `modules/expo-android-nfc/android/src/main/java/expo/modules/androidnfc/`.
The service emulates a read-only NFC Forum Type 4 Tag containing one NDEF URI record.
Expand Down Expand Up @@ -391,6 +392,36 @@ Compatible JS-only changes can use OTA only after that binary exists.
These tests do not execute Kotlin APDUs, modal lifecycle, auth/check-in effects, or physical-device interoperability.
See [NFC behavior](/repositories/d-sports-engage-native/feature-mapping#android-nfc-sharing-and-arena-check-in) for the shipped entry point and failure limits.

## iOS Core NFC configuration

PR #1450 adds the local Swift module `modules/expo-ios-nfc/` and registers `plugins/withIosNfc.js` in `app.json`.
It is separate from `plugins/withAndroidNfc.js` and from the [App Clip](#app-clip-configuration) target.
See [iOS Core NFC arena check-in](/repositories/d-sports-engage-native/feature-mapping#ios-core-nfc-arena-check-in) for the user-facing flow.

At prebuild, the plugin merges `TAG` into `com.apple.developer.nfc.readersession.formats` without duplicates and strips the deprecated `NDEF` value.
It keeps an existing non-empty `NFCReaderUsageDescription` unless the plugin's `usageDescription` option overrides it.
It writes `DSportsNfcAllowedHost` as a bare lowercase host from `extra.appWebHost`, defaulting to `app.d-sports.org`.
The App ID and provisioning profile must also enable NFC Tag Reading; the plugin does not provision it.

`ExpoIosNfcModule.swift` exposes `getStatus`, `isNfcAvailable`, `startScan`, `stopScan`, and the `onNfcUrlDiscovered` / `onNfcError` events.
The podspec targets iOS 17.0 and links `CoreNFC`.
`IosNfcReaderCoordinator.swift` runs one `NFCNDEFReaderSession` at a time with `invalidateAfterFirstRead: true`; a new scan invalidates the previous session.
`IosNfcUrlValidator.swift` reads only the first non-empty well-known URI or absolute-URI record; if that URL fails validation, the tag counts as unsupported even when a later record would pass.
It requires HTTPS, `app.d-sports.org` or `DSportsNfcAllowedHost`, at most 512 characters, and no raw or percent-decoded `..`.
The path must be exactly one segment after `/clip/arena/`, `/profile/`, or `/binder/`.
Arena IDs must match `^[A-Za-z0-9_-]{1,128}$`; profile and binder IDs must match `^[A-Za-z0-9._@-]{1,128}$`.
These path rules are stricter than Android's `NdefUrlCodec.kt`, which checks the allowed prefix and a non-empty path suffix and leaves identifier formats to the JavaScript route parser.
Errors use the codes `UNSUPPORTED_TAG`, `SCAN_TIMEOUT`, `NFC_BUSY`, and `NFC_READ_ERROR`; cancellation is silent.

`lib/ios/nfc.ios.ts` re-validates event URLs with the shared `lib/android/nfc-url.ts` parser.
`RootAuthStack` mounts `hooks/use-ios-nfc-host.ios.ts` through `context/app-providers/IosNfcHost.ios.tsx`.
`features/leaderboard/screen/ScanQrScreen.tsx` renders `components/nfc/NfcArenaScanButton.ios.tsx`.
Non-iOS builds use no-op bridge, host, and button implementations.

Plugin, bridge, host, and button tests do not run Swift, Core NFC, or a real tag.
The Simulator has no NFC reader, so physical arena tags and Android HCE reads need a signed physical-device build.
The module, entitlement, and `Info.plist` keys need a new native binary; an OTA update cannot add them.

## Wallet signing

- Custodial wallets sign on the server via `POST /api/wallets/{address}/sign-transaction`.
Expand Down
39 changes: 36 additions & 3 deletions repositories/d-sports-engage-native/feature-mapping.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ See [architecture](/repositories/d-sports-engage-native/architecture#arena-web-p

For the browser/Android counterpart, see [arena web preview and install handoff](#arena-web-preview-and-install-handoff).

For Android's separate tag-reader and authenticated claim flow using the same arena URL family, see [NFC arena check-in](/repositories/d-sports-engage-native/feature-mapping#android-nfc-sharing-and-arena-check-in).
For the full app's tag reader using the same arena URL family, see [iOS Core NFC arena check-in](#ios-core-nfc-arena-check-in) and Android's separate [NFC arena check-in](/repositories/d-sports-engage-native/feature-mapping#android-nfc-sharing-and-arena-check-in).

An arena invocation such as `https://app.d-sports.org/clip/arena/<id>` opens the iOS 17+ **D-Sports Arena** clip without installing full Engage. Its SwiftUI card displays a public event/club preview, including available team branding, status, venue/start time, and match scores. It does not sign you in, subscribe to live scores, claim a check-in, or award Rep. Invalid links, missing arenas, and network/server failures show **Couldn't Load Arena**; **Try Again** appears when a valid arena ID was extracted. API requests use 10-second request and 15-second resource timeouts.

Expand Down Expand Up @@ -358,7 +358,7 @@ The modal distinguishes NFC-off and HCE-unavailable states.
Sharing requires enabled NFC, HCE, and a current activity.
Scanning requires enabled NFC and a current activity.
**Share link instead** uses the existing share-link fallback.
iOS/web components no-op.
iOS/web tap-to-share components no-op; iOS reads tags through its separate [Core NFC reader](#ios-core-nfc-arena-check-in).
Native start failures return `false`, but the modal ignores that return value.
A ready label therefore does not prove a session started.
Unsupported reader URLs show an error toast; unreadable tags can remain silent.
Expand All @@ -368,7 +368,7 @@ Profile and binder links open their local routes.
An arena tag carries `https://app.d-sports.org/clip/arena/<id>`.
The hook resolves the existing public preview and navigates using `resolveHandoffRoute`.
If the preview supplies `team.id`, it submits an authenticated quest check-in with that team ID.
It does not check `checkInAvailable` before calling the claim client.
It does not check `checkInAvailable` before calling the claim client, unlike the [iOS Core NFC reader](#ios-core-nfc-arena-check-in).
Success sets the arena badge and shows earned Rep.
Already-claimed responses set the badge without another earn toast.
Other claim errors show feedback; thrown errors also log.
Expand All @@ -378,10 +378,43 @@ An allowlisted URL is not proof of attendance or permission to earn rewards.
See the [NFC integration](/repositories/d-sports-engage-native/integration-contracts#android-nfc) for the reused API clients and server-owned contracts.

The [iOS App Clip](/repositories/d-sports-engage-native/feature-mapping#app-clip) uses the same arena URL family with a different handoff flow.
The full iOS app reads the same URLs through [Core NFC](#ios-core-nfc-arena-check-in).
[Apple Wallet passes](/repositories/d-sports-engage-native/feature-mapping#apple-wallet-passes) are signed pass presentation, not this public-link NFC transport.
See [NFC configuration](/repositories/d-sports-engage-native/architecture#android-nfc-configuration) for permissions, lifecycle, native build requirements, and test limits.
Cross-platform phone reading and physical-device interoperability remain unverified by the source tests.

## iOS Core NFC arena check-in

PR #1450 adds foreground Core NFC tag reading to the full iOS app.
It is the iOS counterpart of [Android arena NFC check-in](#android-nfc-sharing-and-arena-check-in), not of Android's tap-to-share.
Engage adds no outbound phone-to-phone NFC sharing on iOS, because Apple restricts Core NFC card emulation to specific entitlements.
The App Clip does not use this reader.

On the arena scanner, **Scan NFC tag** appears beside manual entry, including when camera access is denied.
It renders only where `NFCNDEFReaderSession.readingAvailable` is true, so the Simulator and iPads without an NFC reader never show it.
Tapping it opens the system NFC sheet for one read.
The sheet reads arena tags; reading the URL a nearby Android phone shares is intended but unverified on physical devices.

The reader accepts only an HTTPS `app.d-sports.org` (or configured app host) URL of at most 512 characters.
The path must be one safe identifier after `/clip/arena/`, `/profile/`, or `/binder/`, with no `..`.
An unsupported tag closes the sheet with an error message and also shows an error toast.
Timeouts, a busy reader, and read errors show an error toast; cancelling is silent.

The app waits for sign-in/onboarding before routing and keeps only the latest tag.
The same URL read again within three seconds is ignored.
Profile and binder links open their local routes.
Arena links fetch the public preview and navigate using `resolveHandoffRoute`.
A missing, invalid, or failed preview shows an error toast without navigating.
The app submits an authenticated check-in only when the preview has `checkInAvailable` and `team.id`.
Android, by contrast, attempts the claim whenever `team.id` exists.
Success sets the arena badge and shows earned Rep.
Already-claimed responses set the badge without another earn toast.
Other claim errors show feedback, and there is no durable retry queue.

This reader only runs while its sheet is open.
A tag URL that iOS opens in the background or as a universal link follows the [App Clip](#app-clip) or installed-app link path instead of this reader's claim logic.
See the [Core NFC integration](/repositories/d-sports-engage-native/integration-contracts#ios-core-nfc-arena-check-in) for API clients and [Core NFC configuration](/repositories/d-sports-engage-native/architecture#ios-core-nfc-configuration) for entitlements, build requirements, and test limits.

## Notifications and legal

- Push delivery uses OneSignal. In-app inbox uses `/api/notifications*` and includes `GAME_ALERT` and `RATING`.
Expand Down
11 changes: 10 additions & 1 deletion repositories/d-sports-engage-native/integration-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ A rank refresh does not perform this idle reset.
See [iOS widget configuration](/repositories/d-sports-engage-native/architecture#widget-controls-and-interaction-configuration) for cadence, rebuild requirements, and test limits.
Android's file storage, WorkManager, backoff, and total JS timeout budget below do not describe iOS.

## iOS Core NFC arena check-in

PR #1450 adds an iOS caller of the existing preview and check-in clients, not a new endpoint.
`hooks/use-ios-nfc-host.ios.ts` calls `useApi().quests.getAppClipArenaPreview` (`GET /api/v1/app-clips/arena/{id}`, `404` expected) and `quests.claimArenaCheckIn` from `lib/api/quests-api.ts`.
It requires a preview `kind` of `game_event` or `team` with an `id` before navigating.
It claims with the preview's `team.id` only when `checkInAvailable` is true, unlike the [Android NFC](#android-nfc) host.
A tag URL is not proof of attendance; the server remains authoritative for eligibility, daily limits, and rewards.
See [Core NFC behavior](/repositories/d-sports-engage-native/feature-mapping#ios-core-nfc-arena-check-in) for authentication deferral, feedback, and retry limits.

## Android integration contracts

### Arena preview and install referrer
Expand All @@ -213,7 +222,7 @@ PR #1425 adds an Android caller of existing preview and check-in clients, not a
Use [Platform behavior](/repositories/d-sports-api/platform-infra/behavior#representative-non-admin-platform-routes) for preview routing and the check-in team identifier.
Use [Gamification API](/api-reference/domains/gamification) for the arena check-in endpoint and daily limit.
The hook passes the preview's `team.id`, not the game ID in an event URL.
It attempts a claim whenever that team ID exists, without gating on `checkInAvailable`.
It attempts a claim whenever that team ID exists, without gating on `checkInAvailable`; the [iOS Core NFC](#ios-core-nfc-arena-check-in) host does gate on it.
The server remains authoritative for eligibility and rewards.
See [NFC behavior](/repositories/d-sports-engage-native/feature-mapping#android-nfc-sharing-and-arena-check-in) for authentication deferral, feedback, and retry limits.

Expand Down