This section assumes you've followed our Quickstart section of our Getting Started guide to install and configure our SDK.
Debugging
Purchases will log important information and errors to help you understand what is going on behind the scenes. You can enable more detailed debug logs with the debugLogsEnabled
flag. You can set this immediately in your app while testing, before you configure Purchases.
Purchases.debugLogsEnabled = true
Purchases.configure(withAPIKey: "public_sdk_key", appUserID: "my_app_user_id")
RCPurchases.debugLogsEnabled = YES;
[RCPurchases configureWithAPIKey:@"public_sdk_key" appUserID:@"my_app_user_id"];
Purchases.debugLogsEnabled = true
Purchases.configure(this, "public_sdk_key", "my_app_user_id")
Purchases.setDebugLogsEnabled(true);
Purchases.configure(this, "public_sdk_key", "my_app_user_id");
Purchases.setDebugLogsEnabled(true);
Purchases.setup("public_sdk_key", "my_app_user_id");
Purchases.setDebugLogsEnabled(true);
Purchases.setup("public_sdk_key", "my_app_user_id");
OS_ACTIVITY_MODE
On iOS, disabling
OS_ACTIVITY_MODE
in your XCode scheme will block debug logs from printing in the console. If you have debug logs enabled, but don't see any output, go toProduct -> Scheme -> Edit Scheme...
in Xcode and uncheck theOS_ACTIVITY_MODE
environment variable.
Filtering Purchases Logs
All logs from Purchases SDK are prepended with "[Purchases]
", you can use this string as a filter in your log output to clearly see the logs that are from Purchases.
Sample Output
Below are sample logs generated when setting debugLogsEnabled = true
. Keep an eye out for any ERROR
level logs, status codes other than 200
, or any Invalid Product Identifiers
.
[Purchases] - DEBUG: Debug logging enabled.
[Purchases] - DEBUG: SDK Version - 2.0.0
[Purchases] - DEBUG: Initial App User ID - <APP_USER_ID>
[Purchases] - DEBUG: Changing App User ID: (null) -> <APP_USER_ID>
[Purchases] - DEBUG: GET /v1/subscribers/<APP_USER_ID>
[Purchases] - DEBUG: GET /v1/subscribers/<APP_USER_ID>/products
[Purchases] - DEBUG: Delegate set
[Purchases] - DEBUG: Sending latest purchaser info to delegate
[Purchases] - DEBUG: Vending purchaserInfo from cache
[Purchases] - DEBUG: Vending purchaserInfo from cache
[Purchases] - DEBUG: applicationDidBecomeActive
[Purchases] - DEBUG: No cached entitlements, fetching
[Purchases] - DEBUG: GET /v1/subscribers/<APP_USER_ID> 200
[Purchases] - DEBUG: Purchaser info updated, sending to delegate
[Purchases] - DEBUG: GET /v1/subscribers/<APP_USER_ID>/products 200
[Purchases] - DEBUG: Requesting products with identifiers: {(
onetime,
annual,
onemonth
)}
[Purchases] - DEBUG: Products request finished
[Purchases] - DEBUG: Valid Products:
[Purchases] - DEBUG: annual - <SKProduct: 0x600000308980>
[Purchases] - DEBUG: onemonth - <SKProduct: 0x6000003131b0>
[Purchases] - DEBUG: onetime - <SKProduct: 0x600000313180>
[Purchases] - DEBUG: Invalid Product Identifiers - (
)
[Purchases] - DEBUG: 2 completion handlers waiting on products
[Purchases] - DEBUG: makePurchase - onemonth
[Purchases] - DEBUG: PaymentQueue updatedTransaction: onemonth (null) ((null)) - 0
[Purchases] - DEBUG: PaymentQueue updatedTransaction: onemonth <TRANSACTION_ID> ((null)) - 2
[Purchases] - DEBUG: Finishing onemonth <TRANSACTION_ID> ((null))
[Purchases] - DEBUG: PaymentQueue removedTransaction: onemonth <TRANSACTION_ID> ((null)) - 2
Next Steps
- If you spotted any errors while debugging, make sure you're handling errors correctly
- You've verified that Purchases is running correctly, time to start making purchases in sandbox
Updated about a year ago