In App Purchase API
ironSource App Analytics provides analysis of the application revenue from in-app purchase. Analysis of the items available to purchase. Identify where the places the users purchase them and where those items are placed within the location that yield the best revenue.
Analyzing the in-app purchase revenue within the application rely on two phases:
- Settings API (Pre-init)
- Purchases API (Post-init)
Settings API (Pre-init)
Use this API, prior to SDK initialization, to update the in-app purchase settings available in your application. Only settings declared prior to initialization are available for purchases updates
// The in-app purchase settings API
+(void)setIAPSettings:(ISAnalyticsPurchasingType) purchasingType withValues: (NSArray <NSString *> *) values;
// The in-app purchase settings API
static func setIAPSettings(purchasingType : ISAnalyticsPurchasingType, values : [String])
Parameters
- ISAnalyticsPurchasingType purchasingType – an enumeration of the required in-app purchase item to update. Available values:
- PURCHASE_ITEMS – The official declared purchase items’ names that users can buy within the application (Such as 500 coins, a bundle of 1000 coins and 100 gems etc.)
- Recommended to set according to the application unique offering IDs
- ITEM_CATEGORIES – The categories / groups of items that can be purchased by users or places category (Promo pop up, Bundle in shop, Non depositors offerings etc.)
- PURCHASE_PLACEMENTS – The places / locations where users can purchase items within the application (Such as Shop, between levels, Holiday promo pop up etc.)
- PURCHASE_ITEMS – The official declared purchase items’ names that users can buy within the application (Such as 500 coins, a bundle of 1000 coins and 100 gems etc.)
- NSArray <NSString *> * values – array of String values paired with the required enum. Limited to 100 items per list (Per PurchasingType)
Example of in-app purchase settings API
// Example of in-app purchase settings prior to SDK initialization
// First, set all unique offering IDs, or items, that available in the application
NSArray * iapOffersIDs = [NSArray arrayWithObjects:@"coins_bundle_123", @"gems_offer_10102020", @"holiday_special_300_coins", nil];
[IronSourceAnalytics setIAPSettings:ISAnalyticsPurchasingTypePURCHASE_ITEMS withValues:iapOffersIDs];
// Second, update the offerings categories available in the application
NSArray * iapOfferingCategories = [NSArray arrayWithObjects:@"holiday_promotion", @"non_depositors", @"holiday_promotion", @"begginers_pack", nil];
[IronSourceAnalytics setIAPSettings:ISAnalyticsPurchasingTypeITEM_CATEGORIES withValues:iapOfferingCategories];
// Third, update all locations within the app, or placements, where it is possible // to perform any in-app purchase
NSArray * iapOfferingLocations = [NSArray arrayWithObjects:@"out_of_coins_popup", @"shop_1", @"holiday_popup", @"between_levels_4_5", nil];
[IronSourceAnalytics setIAPSettings:ISAnalyticsPurchasingTypePURCHASE_PLACEMENTS withValues:iapOfferingLocations];
// Example of in-app purchase settings prior to SDK initialization
// First, set all unique offering IDs, or items, that available in the application
let iapOffersIDs : [String] = ["coins_bundle_123", "gems_offer_10102020", "holiday_special_300_coins"]
IronSourceAnalytics.setIAPSettings(ISAnalyticsPurchasingType.PURCHASE_ITEMS, withValues: iapOffersIDs)
// Second, update the offerings categories available in the application
let iapOfferingCategories : [String] = ["holiday_promotion", "non_depositors", "holiday_promotion", "begginers_pack"]
IronSourceAnalytics.setIAPSettings(ISAnalyticsPurchasingType.ITEM_CATEGORIES, withValues: iapOfferingCategories)
// Third, update all locations within the app, or placements, where it is possible // to perform any in-app purchase
let iapOfferingLocations : [String] = ["out_of_coins_popup", "shop_1", "holiday_popup", "between_levels_4_5"]
IronSourceAnalytics.setIAPSettings(ISAnalyticsPurchasingType.PURCHASE_PLACEMENTS, withValues: iapOfferingLocations)
Purchases API (Post-init)
Use this API, following the SDK initialization, to update the users’ in-app purchases (Using the items, placements & categories that were set in the pre-init phase)
// The in-app purchase updates API
+(void)updateUserPurchase:(ISAnalyticsInAppPurchase *_Nonnull) appPurchase;
// The in-app purchase updates API
static func updateUserPurchase(appPurchase : ISAnalyticsInAppPurchase)
Parameters
- ISAnalyticsInAppPurchase appPurchase – The object that represents the purchase event
ISAnalyticsInAppPurchase Object
This object and it’s properties define all the required information regarding a purchasing event
Constructor:
- initWithPurchasedItem:(NSString *) purchasedItem – The item that was purchased by the user. Must be one of the items declared in the setIAPSettings SDK API, in PURCHASE_ITEMS array
Set methods:
- fromCategory:(NSString *) category – The category of the purchased item. Must be one of the item types declared in the setIAPSettings SDK API, in ITEM_CATEGORIES array
- paid:(float) amount – The amount of the money that was used for the purchase
- currency:(NSString * ) currency – Currencies shall be chosen according to ISO 4217 format
- purchasedPlacement:(NSString *) placement – Must be one of the placements the developer passed part of setIAPSettings SDK API, in PURCHASE_PLACEMENTS array
Example of in-app purchase update API
// Example of in-app purchase
ISAnalyticsInAppPurchase *coinsBundle123 = [[[[[[ISAnalyticsInAppPurchase alloc] initWithPurchasedItem:@"coins_bundle_123"]fromCategory:@"holiday_promotion"]paid:15.99]purchasedPlacement:@"out_of_coins_popup"]currency:@"USD"];
[IronSourceAnalytics updateUserPurchase:coinsBundle123];
// Example of in-app purchase
var coinsBundle123 = ISAnalyticsInAppPurchase(purchasedItem: "coins_bundle_123")
.paid(15.99)
.currency("USD")
.purchasedPlacement("purchased_in_shop")
.fromCategory("begginers_pack")
IronSourceAnalytics.updateUserPurchase(coinsBundle123)