Retrieving the customer’s appTransactionID

Below is a code snippet to retrieve a customer’s appTransactionID. Available in Xcode 16.3+.

Apple: The App Store generates a single, globally unique appTransactionID for each Apple Account that downloads your app and for each family group member for apps that support Family Sharing.

This value remains the same for the same Apple Account and app if the customer redownloads the app on any device, receives a refund, repurchases the app, or changes the storefront. For apps that support Family Sharing, the appTransactionID is unique for each family group member.

The appTransactionID is available even if a customer makes no in-app purchases.

private func fetchAppTransaction() async {
    do {
        let result = try await AppTransaction.shared
        guard case .verified(let appTransaction) = result else {
            print("Received unverified app transaction")
            return
        }
        // `appTransactionID`
        print("AppTransaction: \(appTransaction.appTransactionID)")
    } catch {
        print("Failed to fetch app transaction: \(error)")
    }
}

Resources

Leave a comment