Quickstart

This guide describes how to add your app to Apphud and make initial setup.

Create an Apphud Account

You can sign up for a free Apphud account here. Once registered, you will be prompted to add your first app.

Add a New App

If you have just registered, you will see a form to add your first app. Otherwise, click the "Add new app" button on your Dashboard:

App Name

This is the app name that will be used in reports.

iOS App Setup

Bundle ID

To get Bundle ID open App Store Connect, go to "My Apps" and choose your app. At the app page find “Your Bundle ID”.

App Store Shared Secret

To get Shared Secret:

  1. Open App Store Connect, go to my "My Apps" and choose your app.
  2. Select "App Information" submenu.
  3. Click the "App-Specific Shared Secret" link on the right.
  4. Create and copy the Shared Secret.

📘

Important Note

Please make sure that you pasted Shared Secret correctly.

Android App Setup

Package Name

Enter your app's package name.

Google Play Service Account JSON Credentials

For all Android apps you must provide Google Play Service Credentials in order to authorize Google API calls.

Configure Products

Before working with products in SDK, make sure you've made all necessary store setup, i.e. your in-app purchases are configured in App Store Connect / Google Play Console.
Once you configured In-App Purchases, it's time to add their Product IDs to Apphud.
Please read our Configuring Products guide for better understanding the difference between Permission Groups, Paywalls and Products.

To add Product IDs to Apphud, follow our Products guide.

Install SDK

Please follow SDK Installation guide for your platform.

Initialize SDK

Once you successfully installed SDK, you need to initialize it and optionally identify your user with custom User ID / Device ID. Basic initialization looks like this:

Apphud.start(apiKey: "YOUR_API_KEY")
[Apphud startWithApiKey:@"YOUR_API_KEY" userID:nil observerMode:NO];
Apphud.start(this, "YOUR_API_KEY")
await Apphud.start(apiKey: "YOUR_API_KEY", observerMode: false);
await ApphudSdk.start({ apiKey: "YOUR_API_KEY" });

For more details, check our Initialization and Identification guide.

Observer Mode

If you are planning to use your own purchase logic, consider integrating Apphud SDK in Observer (aka Analytics) mode. In this case you are responsible for displaying products, making purchases and finishing / acknowleding transactions. Apphud SDK will only track successful purchases. Check out Observer Mode guide for details.

Display Available Products

Before working with products in SDK, make sure you created all in-app purchases in App Store Connect / Google Play Console, and made necessary set up in Apphud Product Hub. Please follow our Configuring Products guide for details.
Retrieve your paywalls by calling:

Task {
    let mainPaywall = await Apphud.paywall(ApphudPaywallID.main.rawValue)
    let apphudProducts = paywall.products
    // setup your UI with these products
}
Apphud.paywallsDidLoadCallback { paywalls in
    // if paywalls are already loaded, callback will be invoked immediately
    if let paywall = paywalls.first(where: { $0.identifier == "your_paywall_id" }) {
        let products = paywall.products
        // setup your UI with these products
    }
}
[Apphud paywallsDidLoadCallback:^(NSArray<ApphudPaywall *> * _Nonnull paywalls) {        
}];
// somewhere in your singleton class
Apphud.setListener(this)

// implement ApphudListener methods
override fun paywallsDidFullyLoad(paywalls: List<ApphudPaywall>) {
	// method is called when paywalls are loaded with their ProductDetails objects  
}
// Setup ApphudListener and implement this listener (delegate) method:
Future<void> paywallsDidFullyLoad(ApphudPaywalls paywalls);
ApphudSdk.paywallsDidLoadCallback().then((paywalls) => {
   // todo
})

Paywalls must be created in Apphud Product Hub. Each paywall contains an ordered array of products and custom JSON dictionary.
You can retrieve products array by calling paywall.products() on your desired paywall object.
Get mode details in our Displaying Products guide.

Make Purchases

To make a purchase call:

Task {
  	 // productStruct is Product struct model from StoreKit2
     // $isPurchasing should be used only in SwiftUI apps, otherwise don't use this parameter
    let result = await Apphud.purchase(productStruct, isPurchasing: $isPurchasing)
    if result.success {
      // handle successful purchase
    }
}
Apphud.purchase(product) { result in
   if let subscription = result.subscription, subscription.isActive(){
      // has active subscription
   } else if let purchase = result.nonRenewingPurchase, purchase.isActive(){
      // has active non-renewing purchase
   } else {
      // handle error or check transaction status.
   }
}
[Apphud purchase:product callback:^(ApphudPurchaseResult * result) {
    if (result.subcription.isActive){
      // has active subscription
    } else if (result.nonRenewingPurchase.isActive){
      // has active non-renewing purchase
    } else {
      // handle error or check transaction status
    }
}];
Apphud.purchase(activity, product, offerIdToken) { result -> }
await Apphud.purchase(product: product)
ApphudSdk.purchaseProduct(product).then((result) => {
      // todo
});

More details can be found in our Making Purchases guide.

Check Subscription Status

To check subscription status call:

Apphud.hasActiveSubscription()
[Apphud hasActiveSubscription];
await ApphudSdk.hasActiveSubscription();
await Apphud.hasActiveSubscription();
Apphud.hasActiveSubscription()
Apphud.hasActiveSubscription()

Check Premium Access

If you have subscriptions and nonconsumable lifetime purchases, you can use following method to check whether you have active subscription or active nonconsumable. Note, that this method should not be used if you have consumable purchases.

Apphud.hasPremiumAccess()
await Apphud.hasPremiumAccess();
[Apphud hasPremiumAccess];
Apphud.hasPremiumAccess()

More details can be found in our Checking Subscription Status guide.

Advanced Setup

Check out our Additional Resources guide on free trial eligibility checking, handling promoted in-app purchases, sandbox testing, and more.

Next Steps


What’s Next