App Store

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()

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()
    }
  }
}

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

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. Authorize on App Store Connect.

  2. Navigate to the Users and Access section.

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

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

  5. 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.

  2. Fill in the integration form with the data obtained earlier from the App Store:

    • App Bundle ID

    • Issuer ID

    • Key ID

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

  3. 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.

  3. Navigate to App Store Connect. 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.

Last updated

Was this helpful?