Skip to content

Latest commit

 

History

214 Commits

Folders and files

Repository files navigation

Apphud

Greetings!

Apphud SDK is an open-source library for iOS and Android to manage auto-renewable subscriptions and other in-app purchases in your app.

Apphud has SDKs in iOS (Swift), Android (Kotlin), and cross-platform SDKs: React Native and Flutter.

What is Apphud?

Apphud is all-in-one infrastructure for your app growth. Apphud helps marketing and product management teams to make right decisions based on the data and tools.

Subscriptions Infrastructure

Integrate in-app purchases and subscriptions in your mobile app in 2 lines of code. No server code required. Apphud works with all apps on iOS, iPadOS, MacOS, tvOS, watchOS and Android. Cross-platform support out of the box.

Real-time Revenue Analytics

View key subscription metrics in our dashboard and charts, like MRR, Subscriber Retention (Cohorts), Churn rate, ARPU, Trial Conversions, Proceeds, Refunds, etc.

Integrations

Send subscription events to your favorite third party platforms with automatic currency conversion. Choose from 18 integrations, including: AppsFlyer, Adjust, Branch, Firebase, Amplitude, Mixpanel, OneSignal, Facebook, TikTok, and more. Custom Server-to-Server webhooks and APIs are also available.

A/B Experiments

Test different in-app purchases and paywalls. Run experiments to find the best combination of prices and purchase screen parameters that maximize ROI.

Web-to-App (iOS)

Web-to-App solution overcomes IDFA limitations in the post iOS 14.5 era. Using this solution you can run paid campaigns in Facebook or TikTok and get real-time attribution with nearly 100% accuracy.

Rules (iOS & Android)

Apphud may win back lapsed subscribers, reduce churn rate, get cancellation insights, send push notifications and many more using the mechanics below. This mechanics are called Rules. Choose between manual, scheduled and automated rule. Manual rules will be performed manually, scheduled rule will be performed on a certain time, automated rule will be triggered after certain event. Rules can present Figma paywall screens or legacy HTML screens.

React Native integration

  1. Subscribe to rule lifecycle events via ApphudSdkEventEmitter (onApphudRuleScreenDidAppear, onApphudRuleWillPurchase, onApphudRulePurchaseCompleted, onApphudRuleScreenWillDismiss, onApphudRuleScreenDidDismiss, onApphudRuleDidSelectSurveyAnswer, onApphudRulePaywallWithoutScreen). Screens are shown automatically.
  2. Optionally call ApphudSdk.checkRules() to poll for unread rules immediately.
  3. Submit the push token after ApphudSdk.start() via ApphudSdk.submitPushNotificationsToken(...), and forward push payloads with ApphudSdk.handlePushNotification(...).
    • iOS: request notification permission, call registerForRemoteNotifications(), then submit the APNs token / forward userInfo (see the example AppDelegate / ExamplePush).
    • Android: use FCM — submit the registration token and forward message.data (must include rule_id for Apphud rules). See the example ExampleFirebaseMessagingService and ExamplePush module.
  4. Use ApphudSdk.pendingRule() / ApphudSdk.showPendingRuleScreen() when you need pending-rule metadata or to present a delayed screen.
  5. When a Figma paywall rule has no visual screen payload, handle onApphudRulePaywallWithoutScreen and present the paywall yourself (e.g. via PaywallScreenView / createPresenter).

Why Apphud?

Complete mobile in-app purchases stack with no extra costs. Don’t waste time and money on building your own in-app purchases infrastructure. Use Apphud for free until your app revenue increases $10,000 per month.

Focused on data accuracy. Apphud provides the highest accuracy on app revenue tracking. Analyze all important app metrics with a confidence.

Trusted by thousands of mobile apps worldwide. From small apps earning a few thousands per month to a leading mobile-focused companies.

Support that really cares. With Apphud you can be sure you’re not alone with in-app subscription growth challenges. We proud of our zero-ignored tickets support – answering to every request in minutes! Customers success and priority support for Enterprise clients.

Retain users and grow revenue. Use our Rules to engage and re-engage subscribers with no code required. Run A/B pricing experiments to find a better price.

Installation

Create your account at Apphud for free. Please feel free to read our SDK Integration Guide.

iOS (CocoaPods)

This package depends on native ApphudSDK 4.7.2. If pod install fails with “could not find compatible versions”, refresh your spec repo:

cd ios && pod install --repo-update

If the build fails on the fmt pod with a consteval error (common on Xcode 26+), ensure your Podfile post_install sets the fmt target to C++17 — see example/ios/Podfile.


## Deep Link Attribution

Apphud resolves attribution both for **direct** deep link opens (Universal Links / App Links or custom scheme URLs) and for **deferred** attribution right after install. Both results are delivered to a single listener:

```ts
import { ApphudSdk, ApphudSdkEventEmitter } from '@apphud/react-native-apphud-sdk';

const unsubscribe = ApphudSdkEventEmitter.onApphudDeeplinkAttribution(
  ({ attribution, kind, url }) => {
    // kind is 'direct' or 'deferred'. `attribution` is empty when there is no match.
    console.log(kind, url, attribution);
  }
);

Direct deep links

Forward incoming links to the SDK using React Native Linking. getInitialURL covers a cold start from a link, and the url event covers links opened while the app is running:

import { Linking } from 'react-native';

void Linking.getInitialURL().then((url) => {
  if (url) ApphudSdk.handleDeeplinkUrl(url);
});

const subscription = Linking.addEventListener('url', ({ url }) =>
  ApphudSdk.handleDeeplinkUrl(url)
);

Platform setup required for Linking to receive links:

  • iOS: forward the app delegate callbacks to RCTLinkingManager — see example/ios/ExampleApp/AppDelegate.swift. Register your custom scheme under CFBundleURLTypes in Info.plist, and add your Apphud tracking domain to the com.apple.developer.associated-domains entitlement (for example applinks:ddd.aphd.cc) for Universal Links.
  • Android: add ACTION_VIEW intent filters for your scheme and (for App Links) your Apphud domain to the launcher activity — see example/android/app/src/main/AndroidManifest.xml. Since the activity uses singleTask, React Native forwards onNewIntent links to the url event automatically.

Alternatively, if you prefer to forward links from native code, call Apphud.handleOpen(url:) / Apphud.continueUserActivity(_:) in your iOS AppDelegate, or Apphud.handleIntent(intent) in your Android MainActivity's onCreate / onNewIntent. The native Android SDK is exposed transitively, so no extra dependency is needed.

Deferred attribution

Call this after SDK initialization, typically once on first launch. It needs no visible screen. Subscribe to onApphudDeeplinkAttribution before calling it: a result that arrives while no listener is set is not delivered.

await ApphudSdk.requestDeferredDeeplinkAttribution();

The result arrives in onApphudDeeplinkAttribution with kind: 'deferred'.

Breaking change in 4.3.0: attributeFromDeeplink() has been removed. Use handleDeeplinkUrl(url) together with onApphudDeeplinkAttribution, and requestDeferredDeeplinkAttribution() for deferred attribution.

Identity V2

Native dependencies are iOS SDK 4.7.2 and Android SDK 3.7.2. V1 remains the default. Enable V2 explicitly:

await ApphudSdk.start({ apiKey: 'YOUR_API_KEY', identityVersion: 'v2' });
const installation = await ApphudSdk.installationId();
const anonymous = await ApphudSdk.anonymousId();
await ApphudSdk.updateUserID('signed-in-user');

The native SDK generates and stores its own IDs. Logout keeps installationId and changes anonymousId; Identify keeps the anonymous ID. The getters return null in V1 and before initialization. identityVersion is read once per launch; restart the app to change the model.

Wrappers support standalone identity only, without host-supplied installation or anonymous IDs or logout(anonymousId). A custom deviceId remains available for legacy V1 integrations but is rejected in V2, including startManually. When adopting V2, omit it and let the native SDK migrate its saved legacy IDs.

In V2 a reinstall creates a new anonymous customer. Restore recovers previous subscriptions. Only an explicit Restore transfers subscriptions between accounts; purchases and automatic transaction checks do not. Log out before switching users:

await ApphudSdk.logout();
await ApphudSdk.start({
  apiKey: 'YOUR_API_KEY',
  userId: 'next-user',
  identityVersion: 'v2',
});
// User-initiated action; returns the native result after the transfer.
const restored = await ApphudSdk.restorePurchases();

deviceId() is deprecated: it returns the legacy device ID in V1 and the installation ID in V2. Use installationId() in new V2 integrations.

On Android in Observer Mode, call syncPurchasesInObserverMode() after an external purchase. In V2 it synchronizes without transferring another account's purchases. The promise returns the native sync result, including a successful no-op when there is nothing new to sync; a failed or cancelled sync returns false. Use restorePurchases() only for a user-requested transfer. V1 keeps its existing synchronization behavior.

Having a question?

If you have any questions or troubles with SDK integration feel free to contact us. We are online.

https://apphud.com/contacts

Like Apphud? Place a star at the top 😊

Releases

Packages

Used by

Contributors

Languages