React Native
React Native apps (which contain android/ and ios/ sub-projects).
integrate
Section titled “integrate”For a React Native project, alphyn-cli integrate:
- Declares the SDK dependency from the registry. It resolves the latest published version and
pins
@alphyn/react-native-sdkto it inpackage.json, and writes the authenticated.npmrc(the@alphynscope plus a_authTokenthat readsALPHYN_REGISTRY_KEYfrom the environment). No tarball is vendored. Run your package manager afterward (npm install/yarn/pnpm), thencd ios && pod installto link the SDK’s native pod into the iOS workspace. - Adds initialization to your JS entry point (
index.js) on a bare React Native project: a marker-bounded import and anAlphynSDK.initialize()call. (A managed Expo project is wired through the config plugin instead; see Expo.) - Wires the iOS layer when an
ios/directory is present: it merges the requiredInfo.plistkeys (including the attestation-host ATS exception), adds the launch hook to the iOSAppDelegate, and installs the archive post-action into the app’s shared Xcode scheme, creating that scheme when the project has none, so archive builds always auto-register. - Wires the Android layer when an
android/directory is present: it installs a Gradle build hook intoandroid/appso every Android build auto-registers its app hash (the exact same hook a native Android project gets, so the platforms never drift), and registers the authenticated Alphyn package registry as a Maven repository in the android root build script’sallprojects.repositories. That repo registration is required: React Native’s Gradle plugin uses project-level repositories, so Gradle’s default repository mode ignores the SDK module’s own repo and:appcannot resolve the SDK AAR without it. (No nativeMainActivityinit is added, since React Native starts the SDK from JavaScript.) - Records the result in
alphyn.json.
The SDK’s native binaries are no longer bundled in the npm package: the com.byterialab:alphyn-sdk
AAR resolves from the Alphyn package registry through the Gradle repository above, and the iOS
framework is fetched from the registry during pod install. Your build must supply your app API key
as ALPHYN_REGISTRY_KEY. See SDK Registry Access:
export ALPHYN_REGISTRY_KEY=<YOUR_APP_API_KEY>alphyn-cli new react-native scaffolds a starter by delegating to the React Native community
CLI (npx @react-native-community/cli init), so Node and npx must be available.
register
Section titled “register”Nothing to run manually. The iOS build registers at archive time via the post-action, and the
Android build registers at build time via the Gradle hook, both installed by integrate; run
alphyn-cli doctor to confirm they are wired. Pass --apk only to register a specific Android APK
by hand (a split or App Bundle output the hook skips, or a CI step).
A React Native project enrolls under one portal app per platform, each with its own API key
(see How to Register Your App). Give integrate both:
--android-api-key (or --android-api-key-file) is the Android app’s key and
--ios-api-key (or --ios-api-key-file) is the iOS app’s key; the generic --api-key is
not accepted on a React Native project, so a build can never register under the other
platform’s key. integrate writes each into a gitignored .alphyn/ key file that the Gradle
hook and the Xcode archive post-action read automatically, so every build registers with no
further setup. To override per build, point alphyn.api.key.file (Gradle) or
ALPHYN_IOS_API_KEY_FILE (the Xcode archive environment) at a key file; for a manual
register --apk, pass --android-api-key / --android-api-key-file. The backend accepts a
registration only from the matching platform’s key.
Development builds (iOS debug hash)
Section titled “Development builds (iOS debug hash)”During development an iOS app’s hash changes on every build and is never registered (iOS
registration happens at archive time). Pin your app’s development debug hash from the dashboard
(App Details) so npm run ios builds initialize the SDK:
alphyn-cli integrate --android-api-key <key> --ios-api-key <key> --ios-debug-hash <64-hex>The hash is rendered into a __DEV__-guarded branch of the JS initialization, so a release
bundle never carries it, and it is recorded in alphyn.json across re-runs. integrate also
enrolls a development build signature with the backend (this uses the iOS app’s key), which a
dev build needs before its first archive; SDK init in the dev loop then succeeds when the
pinned hash matches the app’s dashboard debug hash. --android-debug-hash exists for the
deliberate Android cases (a build environment without the hook, or pinning one specific
registered build); normally the Gradle hook already registers every Android build.
The enrollment needs no build and no archive: it is a pure CLI call, and the development
build signature appears in the dashboard as soon as it runs. register performs the same
enrollment, so once the hash is pinned you can re-ensure it at any time without a full
re-integrate (the pinned hash is recorded, so later runs need no flag; the iOS key comes from
--ios-api-key or the provisioned .alphyn/ios-api.key):
alphyn-cli register --android-api-key <key>The enrollment is idempotent, and alphyn-cli doctor reports the development build signature
as enrolled. A real archive-time signature does not require the Xcode UI either:
xcodebuild runs the same scheme post-action, so a terminal or CI archive registers itself
(the usual signing requirements apply; a simulator build is not an archive):
cd iosxcodebuild -workspace <App>.xcworkspace -scheme <AppScheme> -configuration Release \ -destination 'generic/platform=iOS' archive -archivePath build/App.xcarchiveThe iOS launch hook requires a Swift
AppDelegate. If your app still uses an Objective-CAppDelegate,doctorreports it clearly rather than installing a hook that would not run.
doctor
Section titled “doctor”Confirms the package.json dependency and the authenticated .npmrc that resolves it, the JS
initialization is present as real code, the iOS layer, the Android build hook and registry Maven
repository (each when present), and the minSdk advisory. When a development debug hash is pinned,
it also reports whether the development build signature is enrolled on the backend (advisory; it
never fails the run).
remove
Section titled “remove”Removes the package.json dependency and the managed .npmrc, the JS initialization, the iOS
edits, the Android layer (build hook + registry Maven repository), any tarball it vendored, and
alphyn.json.