Expo SDK Guide
🚀 Expo — config plugin over the React Native bridge
@billdog.io/expo re-exports the React Native SDK and adds an Expo config plugin that wires the native projects during prebuild, so you never edit the Podfile or Gradle files by hand.
Expo Go will not work
npx expo run:ios / run:android, or EAS Build). In Expo Go the package still imports, so you can branch with isExpoGo(), but the native SDK is not there: purchase() and restore() return a failed result, and the offering reads reject, with the code NATIVE_MODULE_UNAVAILABLE and a message that says a development build is needed; getCustomerInfo() returns null and BillDogAuth.isAvailable is false.1. Install
npx expo install @billdog.io/expo@^1.2.0-beta.1 \
@billdog.io/react-native@^1.2.0-beta.1 \
@react-native-async-storage/async-storage@^1.19.0 \
react-native-fs@^2.20.0 \
react-native-svg@^13.0.0 \
react-native-webview@^13.0.0@billdog.io/expo wraps the React Native SDK, and the four packages after it are that SDK’s native peer dependencies. Through SDK 53, Expo autolinks only the packages listed in your app’s own package.json — not the dependencies of the packages you install — so the bridge and its native peers are installed by name. expo install keeps a range you give it instead of substituting the version Expo recommends, so each lands within the range the SDK declares. The local-notification helpers also need react-native-push-notification; it is an optional peer, and without it those helpers fail with NATIVE_MODULE_UNAVAILABLE while the rest of the SDK works.
Add the plugin to your app.json (or app.config.js):
{
"expo": {
"plugins": ["@billdog.io/expo"]
}
}It needs no options. (Its oauthRedirectUri option was for Sign in with Apple on Android, which no longer needs a redirect of your own; it is still accepted.)
Then generate the native projects and run a dev build:
npx expo prebuild
npx expo run:ios # or: npx expo run:androidWhat the plugin does
pod 'BillDogReactNative' pointing at the bundled React Native bridge, which in turn pulls the native BillDogFull pod. Android needs no dependency wiring — autolinking finds the bridge module, which is on the install line for that reason, and it pulls the Maven artifact itself. What the plugin adds on Android is the OAuth redirect intent filter, and only when you pass oauthRedirectUri.The plugin raises the iOS deployment target to 15.0
ios.deploymentTarget in ios/Podfile.properties.json (which the Podfile’s platform :ios line reads) and the app project’s IPHONEOS_DEPLOYMENT_TARGET to 15.0 — the same two settings expo-build-properties writes. It only ever raises the target: SDK 52 and later (15.1) and any higher target you set are left as they are.2. Configure
Configure once at startup. Use a named import — the package has no default export — and note configure is on BillDogConfiguration, not on BillDog.
import { BillDogConfiguration } from '@billdog.io/expo';
BillDogConfiguration.configure({
apiKey: 'YOUR_API_KEY_HERE', // starts with bd_public_test_ or bd_public_live_
});3. Manage customer identity
This links a user you have already authenticated
import { BillDog } from '@billdog.io/expo';
await BillDog.logIn('user_uuid_123');
// …or identify with attributes for segmentation
await BillDog.identify('user_uuid_123', { plan: 'trial' });
BillDog.isAnonymous(); // -> boolean
BillDog.getAppUserId(); // -> string | null
await BillDog.logOut();4. Present a paywall
Register a placement and let BillDog decide which paywall to show:
import { BillDog } from '@billdog.io/expo';
const result = await BillDog.register('onboarding');
// result.type: 'entitled' | 'purchased' | 'dismissed' | 'restored'
// | 'holdout' | 'withheld' | 'error'Or render a specific paywall inline:
import { PaywallView } from '@billdog.io/expo';
export function PremiumScreen() {
return <PaywallView paywallIdentifier="premium_offer" />;
}5. Check entitlements
import { BillDog } from '@billdog.io/expo';
// Asks the server; false on any error (fails closed)
if (await BillDog.hasAccessForPlacement('premium_features')) {
// unlock
}
const info = await BillDog.getCustomerInfo();
const hasPro = info?.entitlements.some(
(e) => e.identifier === 'pro' && e.isActive
);
await BillDog.restore();6. Sign users in (BillDog Auth)
Needs a dev build and native binaries 1.0.2-beta.3 or later (use 1.2.0-beta.1)
BillDogFull built before it contains no BillDogAuth, and Maven Central carries no io.billdog:billdog-auth at any version before 1.0.2-beta.3, so a build that resolves an older pin fails to compile. And like the rest of BillDog’s native code it is not in Expo Go at any version: there BillDogAuth.isAvailable is false (see the warning at the top of this page).@billdog.io/expo re-exports BillDogAuth from @billdog.io/react-native, which owns the native bridge — so the refresh token lives in the iOS Keychain and Android EncryptedSharedPreferences, never in AsyncStorage. Nothing extra to install: the config plugin you added in step 1 links it.
import { BillDogAuth } from '@billdog.io/expo';
// False when the native auth module is not linked into your build.
if (!BillDogAuth.isAvailable) return;
const restored = await BillDogAuth.restore(); // { signedIn: false } on first launch
// signedIn: false + hasStoredSession: true → offline or a server error, still signed in
const r = await BillDogAuth.attempt({
identifier: 'ada@example.com',
strategy: 'password',
password,
});
if (r.mfaRequired) {
await BillDogAuth.attempt({
identifier: 'ada@example.com',
strategy: 'totp',
code,
mfaToken: r.mfaToken,
});
}Read mfaRequired before you treat the result as a sign-in: against an enrolled account a correct password issues no session. The server spends the challenge before it verifies the code, so a wrong second factor is a restart, not a retry — the mfaToken is dead and you go back to the first factor for a new one.
Phone sign-in needs kind on both calls. It selects the identity row, it defaults to email, and omitting it looks a phone number up among email addresses, matches nothing, and returns the same opaque 401 as a wrong password:
await BillDogAuth.requestCode({ identifier: '+15551234567', kind: 'phone' });
await BillDogAuth.attempt({
identifier: '+15551234567',
kind: 'phone', // REQUIRED — selects the identity row
strategy: 'sms_code',
code,
});7. Social sign-in
One call starts it, and what happens next differs by provider. Read mfaRequired first, then verified, not success; on success the native module adopts the session itself and no token crosses the bridge.
// Facebook needs no configuration on the device — BillDog holds it.
const r = await BillDogAuth.signInWithOAuth('facebook');
if (r.mfaRequired) {
// No session yet. Finish with the second factor; the token names the account.
await BillDogAuth.attempt({ strategy: 'totp', code, mfaToken: r.mfaToken });
} else if (r.verified) {
/* signed in */
}
// Google on Android uses Google Play Services, so it needs the wall's
// oauth_providers block. Apple and Facebook (and Google on iOS) ignore it.
await BillDogAuth.signInWithOAuth('google', oauthProviders);Facebook, Google on iOS and Apple on Android need nothing from your app
BillDogAuth.handleOAuthRedirect is no longer needed; calling it is harmless.Sign-up requirements, password reset and account deletion
// What the project requires before it accepts a sign-up
const cfg = await BillDogAuth.config(); // { accessMode, botProtection, turnstileSiteKey, ... }
await BillDogAuth.signUp({
identifier: 'ada@example.com',
password,
invitationToken, // required when cfg.accessMode is 'invite_only'
captchaToken, // required when cfg.botProtection is true (a Turnstile token)
});
// Password reset: send a code, then set the new password with it.
// Pass the same kind to both calls for a phone number.
await BillDogAuth.requestPasswordReset({ identifier: 'ada@example.com' });
await BillDogAuth.resetPassword({ identifier: 'ada@example.com', code, newPassword });
// Delete the signed-in user's own account. Rejects with code REAUTH_REQUIRED
// when the sign-in is too old: sign the user in again, then retry.
await BillDogAuth.deleteAccount();The rest of the surface — signOut, passkeys, BillDogAuth.organizations — is in the React Native guide, the auth quickstart, Sessions & Tokens and Multi-Factor.
8. Expo-specific helpers
The package also exports three helpers that read expo-constants:
isExpoGo()istrueinside Expo Go, where BillDog’s native features are unavailable.isStandaloneBuild()istruewhen the app runs from its own native build — a development or release build, from EAS Build or a localexpo run— which is where BillDog’s native modules are linked. It isfalsein Expo Go and on web.getExpoSdkVersion()returns your project’s Expo SDK version, such as'53.0.0': thesdkVersionof the app config embedded in the build, which Expo fills in from your installedexpopackage.
import { isExpoGo, getExpoSdkVersion } from '@billdog.io/expo';
if (isExpoGo()) {
// Purchases, offerings and auth need a development build.
}
getExpoSdkVersion(); // -> '53.0.0'Next steps
- Everything in the React Native guide applies — Expo re-exports that API surface.
- Platform behaviour lives in the iOS and Android guides.
- BillDog Auth — sign users in, and gate features on the token instead of a round-trip.
- SDK glossary — placements, offerings and entitlements.
Was this page helpful?
Or rate this page: