Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io

    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.

    View on npmConfig plugin • Dev build • iOS 15+ • Android 21+

    1. Install

    Terminal
    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):

    app.json
    {
      "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:

    Terminal
    npx expo prebuild
    npx expo run:ios      # or: npx expo run:android

    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.

    App.tsx
    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

    TypeScript
    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:

    TypeScript
    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:

    TSX
    import { PaywallView } from '@billdog.io/expo';
    
    export function PremiumScreen() {
      return <PaywallView paywallIdentifier="premium_offer" />;
    }

    5. Check entitlements

    TypeScript
    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)

    @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.

    TypeScript
    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:

    TypeScript
    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.

    TypeScript
    // 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);

    Sign-up requirements, password reset and account deletion

    TypeScript
    // 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() is true inside Expo Go, where BillDog’s native features are unavailable.
    • isStandaloneBuild() is true when the app runs from its own native build — a development or release build, from EAS Build or a local expo run — which is where BillDog’s native modules are linked. It is false in Expo Go and on web.
    • getExpoSdkVersion() returns your project’s Expo SDK version, such as '53.0.0': the sdkVersion of the app config embedded in the build, which Expo fills in from your installed expo package.
    TypeScript
    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:

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.