You can record App Store subscriptions and verify their validity with the Adjust SDK. After the user purchases a subscription, create an ADJSubscription
instance containing the details.
1. Instantiate a subscription object
- (nullable id)initWithPrice:(nonnull NSDecimalNumber *)price currency:(nonnull NSString *)currency transactionId:(nonnull NSString *)transactionId;
To get started, you need to create a subscription object containing details of the subscription purchase. To do this, initialize an ADJSubscription
object using the initWithPrice
method. Pass the following arguments:
Parameter | Data type | Description |
---|---|---|
price | NSDecimalNumber | The price of the subscription |
currency | NSString | The currency of the subscription. Formatted as the currencyCode of the priceLocale object |
transactionId | NSString | Your ID for the transaction |
receipt | NSString | The receipt information |
Record the purchase date
- (void)setTransactionDate:(nonnull NSDate *)transactionDate;
You can record the date on which the user purchased a subscription. The SDK returns this data for you to report on. Call the setTransactionDate
method with a timestamp to record this information.
Record the purchase region
- (void)setSalesRegion:(nonnull NSString *)salesRegion;
You can record the region in which the user purchased a subscription. To do this, call the setSalesRegion
method on your subscription object and pass the country code as an NSString
. This needs to be formatted as the countryCode
of the priceLocale
object.
Add callback parameters
- (void)addCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value;
You can add callback parameters to your subscription object. The SDK appends these parameters to your callback URL. To add callback parameters, call the addCallbackParameter
method on your subscription object. You can add multiple callback parameters by calling this method multiple times.
Add partner parameters
- (void)addPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value;
You can add partner parameters to your subscription object. The SDK sends these to Adjust’s servers when the user purchases a subscription. Adjust’s servers forward the information on to your network partner. To add partner parameters, call the addPartnerParameter
method on your subscription object. You can add multiple partner parameters by calling this method multiple times.
2. Send subscription information
+ (void)trackSubscription:(nonnull ADJSubscription *)subscription;
Once you have set up your subscription object, you can send it to Adjust using the Adjust SDK. Pass your completed object to the trackSubscription
method to record the user’s subscription purchase.