LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
    • Acquisition Example
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • SDK integration
  • Subscription restore
  • Settings on the App Store Connect side
  • Settings on devtodev side
  • In-App Purchases
  • Subcriptions

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 2.0+
  3. Automatic payment tracking

App Store

PreviousAutomatic payment trackingNextGoogle Play

Last updated 1 month ago

Was this helpful?

1

2

3

SDK integration

Prerequisites:

Native SDK

  • StoreKit SDK v1

  • DTDAnalytics SDK 2.5.0 and higher

Unity

  • DTDAnalytics 3.9.0

  • DTDPurchases 3.9.0

To initialize the service, call the startAutoTracking method of the DTDPurchases interface. Call the method after the SDK initialization call:

let config = DTDAnalyticsConfiguration()
DTDAnalytics.initialize(applicationKey: "App ID", configuration: config)
DTDPurchases.startAutoTracking()
DTDAnalyticsConfiguration *config;
[DTDAnalytics applicationKey:@"App ID" configuration:config];
[DTDPurchases startAutoTracking];
DTDAnalytics.Initialize(APPKey, new DTDAnalyticsConfiguration
{
  UserId = userId,
  ApplicationVersion = Application.version,
  CurrentLevel = lvl,
  LogLevel = DTDLogLevel.No,
  TrackingAvailability = DTDTrackingStatus.Enable
});
DTDPurchases.StartAutoTracking();

Subscription restore

Subscription renewals, cancellations, and other status changes are tracked using server-to-server data from the App Store. See the following sections for setup.

In order to be able to track status changes for subscriptions that were issued prior to the devtodev SDK integration, you must send the history of previously purchased user subscriptions to devtodev.

The SDK keeps track of the need to send this historical data so that it does not make “unnecessary” requests to the App Store. Use the isRestoreTransactionHistoryRequired method to check whether it is necessary to send data about previously purchased subscriptions to devtodev.

The isRestoreTransactionHistoryRequired method returns a BOOL value.

Here is an example of a purchase history request with the check:

DTDAnalytics.isRestoreTransactionHistoryRequired { isNeedRestore in
  if isNeedRestore {
    DispatchQueue.main.async {
      SKPaymentQueue.default().restoreCompletedTransactions()
    }
  }
}
[DTDAnalytics isRestoreTransactionHistoryRequiredWithCompletionHandler:^(BOOL isNeedRestore){
  if (isNeedRestore == true) {
    dispatch_async(dispatch_get_main_queue(), ^{
      [SKPaymentQueue.defaultQueue restoreCompletedTransactions];
    });
  }
}];
if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer)
{
  var apple = storeExtensionProvider.GetExtension<IAppleExtensions>();
  DTDAnalytics.IsRestoreTransactionHistoryRequired((required) =>
  {
    if(!required) return;
    apple.RestoreTransactions((success, text) =>
    {
      Debug.Log(success ? $"Purchases restored successfully on iOS." : $"{text}");
    });
  });
}

Settings on the App Store Connect side

To get detailed information about the transaction, devtodev requires access to the App Store Server API. To grant this access, you will need to generate an In-App Purchase API key.

Generating the key:

  1. Navigate to the Users and Access section.

  2. In the Integrations tab (1), select In-App Purchase from the menu on the left (2), and click (+) to add the key (3).

  3. Specify the name of the key, for example: "devtodev API Key", and click Generate.

  4. To grant the necessary access to the devtodev service, it is necessary to pass the following information:

    • Issuer ID

    • Key ID

    • The generated .p8 file of the In-App Purchase key

    • Bundle identifier of the application (App Bundle ID)

Settings on devtodev side

In-App Purchases

  1. Go to Settings → Payments integration → IAP auto tracking → Integrate.

    • App Bundle ID

    • Issuer ID

    • Key ID

    • Upload the .p8 file of the In-App Purchase key.

  2. When the integration is complete, the status will change to Active.

Subcriptions

  1. In order for IAP auto tracking to work correctly with subscriptions, you need to integrate App Store Server Notification. Go to Settings → Payments integration → Subscriptions → Integrate.

  2. Fill in the iOS Bundle ID and copy the Endpoint URL.

DTDPurchases service will get the information about previously purchased subscriptions automatically from SKPaymentQueue. Sending the data via the method is not required.

Authorize on .

Fill in the integration form with the data :

Navigate to . In the left menu column, under General, go to App information. Paste the copied endpoint URL into the Production Server URL and Sandbox Server URL fields. Click Save to confirm your changes.

App Store Connect
App Store Connect
SDK Integration
Settings on the App Store Connect side
Settings on devtodev side
For In-App Purchases
For Subscriptions
obtained earlier from the App Store
subscriptionHistory