Back to Docs

iOS App & Monetization Setup

A step-by-step guide to creating your app listing on App Store Connect, adding in-app purchases, and testing with TestFlight and B4X Purchase Manager.

Prerequisites

• An Apple Developer Program membership ($99/year)

• A B4i project ready to compile

• A provisioning profile based on an explicit (non-wildcard) App ID (see below)

• The Paid Apps agreement accepted in App Store Connect (Agreements, Tax, and Banking)

• A B4X Purchase Manager account with an app and API key created

Set up your provisioning profile before adding b4xlib

The b4xlib references the iStore library, which requires a valid provisioning profile based on an explicit (non-wildcard) App ID. Your B4i project will not compile if you add the b4xlib without a provisioning profile configured first.

In the Apple Developer Portal, create an explicit App ID (e.g. com.yourcompany.yourapp, not com.yourcompany.*), generate a Development provisioning profile for it, then add both to your B4i project before adding the b4xlib to your project:

#ProvisionFile: your_dev_profile.mobileprovision
#CertificateFile: ios_development.cer
1

Create an explicit App ID (Bundle ID)

In-app purchases require an explicit (non-wildcard) Bundle ID. If you're using a wildcard like com.yourcompany.*, you'll need to create a specific one.

• Go to Certificates, Identifiers & Profiles in the Apple Developer portal

• Click Identifiers + to register a new identifier

• Select App IDs App

• Enter a description and an Explicit Bundle ID (e.g. com.yourcompany.yourapp)

• Under Capabilities, make sure In-App Purchase is checked (it's on by default)

• Click Continue then Register

2

Create your app in App Store Connect

Go to App Store Connect → My Apps and click the + button to create a new app:

Platform — iOS

Name— your app's display name on the App Store

Primary Language — usually English

Bundle ID — select the explicit Bundle ID you created in Step 1

SKU — a unique identifier for your records (e.g. yourapp_ios_v1)

• Click Create

3

Accept the Paid Apps agreement

Before you can create in-app purchases, you must accept the Paid Apps agreement:

• Go to App Store Connect → Agreements, Tax, and Banking

• Find the Paid Apps agreement and accept it

• Fill in your banking and tax information as required

This is required even for free apps that have in-app purchases. Without it, the Subscriptions and In-App Purchases sections won't appear.

4

Create in-app purchases

In your app's page in App Store Connect:

For subscriptions:

• Go to the Subscriptions section in the sidebar

• Create a Subscription Group (e.g. "Premium")

• Click Create within the group to add a subscription

• Set the Reference Name and Product ID (e.g. premium_monthly)

• Configure duration, price, and localisation

• The status should show Ready to Submit

For one-time purchases:

• Go to the In-App Purchases section in the sidebar

• Click + to create a new in-app purchase

• Select the type: Consumable or Non-Consumable

• Set the Reference Name and Product ID

• Add pricing and a screenshot (required for review, can be a simple placeholder)

First submission requirement

Your first in-app purchase must be submitted with a new app version for review. After the first one is approved, you can add more without a new app version. The product status will show "Ready to Submit" until then.

5

Create a Sandbox test account

Sandbox accounts let you test purchases without being charged.

• In App Store Connect, go to Users and Access → Sandbox

• Click + to create a new Sandbox tester

• Use any email address (it doesn't need to be a real Apple ID — Apple creates a sandbox-only account)

• Set a password, name, and storefront region

On your test device, go to Settings → App Store → Sandbox Account and sign in with the sandbox tester credentials. This keeps your real Apple ID separate.

6

Upload a build and test with TestFlight

You don't need to upload to test purchases

Unlike Google Play, iOS doesn't require an uploaded build before you can test in-app purchases. You can run your app directly from B4i onto a device with a sandbox account and test the full purchase and validation flow immediately. This step is only needed when you're ready to distribute via TestFlight or submit to the App Store.

When you're ready to distribute, you'll need a Distribution certificate and an App Store Distribution provisioning profile (different from the Development ones used for testing).

Upload steps in B4i:

• Create a Distribution certificate and App Store provisioning profile in the Apple Developer Portal

• In your B4i main module, set the distribution certificate and profile:

#CertificateFile: ios_distribution.cer
#ProvisionFile: your_appstore_profile.mobileprovision

• Compile your project (Release mode)

• Go to Tools → Build Server → Download Last Build to download the signed IPA

• Then go to Tools → Build Server → Upload App to App Store Connect

• Enter your Apple ID and an app-specific password (generate one at appleid.apple.com under Sign-In and Security → App-Specific Passwords)

Once uploaded, manage it in App Store Connect:

• In App Store Connect, go to TestFlight

• The build will appear after processing (usually a few minutes)

• For internal testing, add testers from your team — no review needed

• For external testing, create a group and submit for Beta App Review (usually quick)

• Testers install via the TestFlight app on their device

TestFlight + Sandbox purchases

Apps installed via TestFlight automatically use the sandbox environment for purchases. When a tester triggers a purchase, it uses their sandbox account — no real money is charged. Make sure the sandbox account is signed in under Settings → App Store → Sandbox Account.

7

Configure b4xlib and test

In your B4i project, initialize the PurchaseManager:

PurchaseManager.Initialize(Root, BILLING_KEY, APP_ID, API_KEY)

BILLING_KEY = your Google Play license key (ignored on iOS)
APP_ID = your App ID from B4X Purchase Manager dashboard
API_KEY = your API key from B4X Purchase Manager dashboard

Also make sure you've uploaded your Apple Shared Secret in the dashboard — it's required for receipt validation.

Common Issues

"Cannot connect to iTunes Store"

This is a StoreKit error shown on-device. Common causes: the Paid Apps agreement hasn't been accepted in App Store Connect, your in-app products aren't in "Ready to Submit" status yet, or the device has a network connectivity issue. Check App Store Connect → Agreements, Tax, and Banking first.

"No products available" or empty product list

The product isn't in "Ready to Submit" status, the Bundle ID doesn't match, or the Paid Apps agreement isn't active. Products can also take up to an hour to propagate after creation.

Purchases work but validation fails

Make sure you've uploaded the Apple Shared Secret in the dashboard. Without it, Apple rejects receipt validation for subscriptions.

Sandbox purchases prompting for real payment

You're not signed into a sandbox account. Go to Settings → App Store → Sandbox Account on your device and sign in with your sandbox tester credentials.

Subscription renewals in sandbox

Sandbox subscriptions renew at an accelerated rate (e.g. a monthly subscription renews every 5 minutes). They auto-cancel after about 12 renewals. You can adjust the renewal speed in App Store Connect under the sandbox tester settings.