Using the SDK
Using Apphud SDK:
After you successfully installed Apphud SDK follow these guides on how to:
Additional Resources
Migrate Existing Paying Users
If your app has existing paying users, you need to migrate them to Apphud. Please our Data Migration Guide for details.
Prepare SDK for Integrations
Some integrations require you to match user ids between Apphud and corresponding integration. For example, if you want to use AppsFlyer integration, you must submit AppsFlyer attribution with AppsFlyer ID to Apphud.
Please see the documentaion guide for your desired integration.
Configure Push Notifications (iOS)
Configuring push notifications is highly recommended in order to use Rules – a powerful feature that lets you increase your app revenue by automatically offering a discount to a user at the specified moment.
User Properties
Apphud SDK allows you to pass User Properties, which can later be used in Dashboard Charts and User filtering. See User Properties guide for details.
Handle Promoted In-App Purchases (iOS)
Note
Do not get confused with Promotional Offers! Promoted in-app purchases are the ones that appear in the App Store page.
If you have in-app purchases that can be purchased directly from the App Store, you should implement a logic to continue a payment in the app.
To continue an in-app purchase transaction initiated from the App Store page, please implement the following ApphudDelegate
method:
func apphudShouldStartAppStoreDirectPurchase(_ product: SKProduct) -> ((ApphudPurchaseResult) -> Void) {
// manage your UI here, show a progress hud, etc.
let callback : ((ApphudPurchaseResult) -> Void) = { result in
// check the result, hide a progress hud, etc.
}
return callback
}
- (void (^)(ApphudPurchaseResult * _Nonnull))apphudShouldStartAppStoreDirectPurchase:(SKProduct *)product {
// manage your UI here, show a progress hud, etc.
return ^(ApphudPurchaseResult * _Nonnull result) {
// check the result, hide a progress hud, etc.
};
}
Important Note
To avoid conflicts make sure promoted In-App purchases are handled only by Apphud SDK in your app code, i.e. double check that
paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool
is implemented just once.
You must return a callback block which will be called when a payment is finished. If you don't implement this method or return nil
then a payment will not start; you can also save the product and return nil to initiate a payment later by yourself. You can also read Apple documentation for details.
Testing Integrations in Sandbox
To test integrations, ensure that test credentials are provided in your integration settings (if available) and make a sandbox in-app purchase.
Note
Starting iOS 14 you can reset your trial eligibility in iOS Settings > App Store
On Android, you can cancel your existing sandbox subscriptions in Google Play app.
For more details regarding Testing In-App Purchases, read SDK Testing (iOS) and SDK Testing (Android) guides.
Apphud will send all subscription events of current user to your test analytics, if test credentials are set in integration settings.
Note
Sandbox events will never be sent to your production integrations. If test credentials are not provided, sandbox events will not be sent anywhere.
Note
You can also click on "Send Test Event" near the integration's "..." button. This feature is available only for some Integrations.
User Eligibility for Introductory Offer (iOS)
You can read more about eligibility testing here.
You can use Apphud to determine if user is eligible for introductory offer:
// Check eligibility for introductory offer
Apphud.checkEligibilityForIntroductoryOffer(product: myProduct) { result in
// handle result
}
// Check eligibility for multiple products at one call
Apphud.checkEligibilitiesForIntroductoryOffers(products: products) { resultDict in
// handle result
}
// Check eligibility for introductory offer
[Apphud checkEligibilityForIntroductoryOfferWithProduct:myProduct callback:^(BOOL eligible) {
// handle result
}];
// Check eligibility for multiple products at one call
[Apphud checkEligibilitiesForIntroductoryOffersWithProducts:productsArray callback:^(NSDictionary * resultDict) {
// handle result
}];
User Eligibility for Promotional Offer (iOS)
You can read more about eligibility testing here
You can also use Apphud to determine if user is eligible for promotional offer:
// Check eligibility for promotional offer
Apphud.checkEligibilityForPromotionalOffer(product: myProduct) { result in
// handle result
}
// Check eligibility for multiple products at one call
Apphud.checkEligibilitiesForPromotionalOffers(products: products) { resultDict in
// handle result
}
iOS SDK Reference
iOS SDK Reference is available here.
Updated 9 months ago