• Save
In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]
Upcoming SlideShare
Loading in...5

In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010]



In-App Purchase offers a great way for your users to enhance your application after the sale by purchasing additional material: new game levels, in-game goods, and subscriptions to new content. For ...

In-App Purchase offers a great way for your users to enhance your application after the sale by purchasing additional material: new game levels, in-game goods, and subscriptions to new content. For the user, it's just a few taps, and an easy payment from their iTunes account. For the developer, however, In-App Purchase requires a major effort: creating and hosting digital products, developing and hosting authentication servers, managing products in iTunes Connect, and more. Don't let the small size of the Store Kit framework fool you: offering in-app purchases goes far beyond that. In this talk, we'll go through all the steps of selling products through I-AP, pointing out the unexpected benefits and problems that come with it. We'll also reveal iPhone frameworks that, while not technically part of I-AP, are vital for successful and secure purchase-based applications. Finally, we'll look at cases where you might want to use I-AP, and others where it makes better business sense not to.



Total Views
Slideshare-icon Views on SlideShare
Embed Views



3 Embeds 52

http://www.slideshare.net 48
http://www.techgig.com 3
http://webcache.googleusercontent.com 1



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010] In-App Purchase: Best/Worst Thing Ever [Voices That Matter: iPhone 2010] Presentation Transcript

    • In-App Purchase: Best/Worst Thing Ever Chris Adamson @invalidname Voices That Matter: iPhone Developer Conference 2010
    • What You’ll Learn Today The many parts of I-AP Using Store Kit in your app Everything else you need to do in-app purchase Good reasons to use… and not to use… in-app purchase
    • In-App Purchase Added in iPhone OS 3.0 Allows user to make purchases within an app, using their iTunes account Apple keeps 30%
    • I-AP Examples Digital books Magazine subscriptions Data plans (e.g., map services) Gaming: New levels Customizations
    • Item Shops
    • If VTM were an online game Default clothing would be boring You could purchase virtual VTM clothing and other items to bling out your avatar This will be our example…
    • Our fun VTM online game …minus the actual game
    • Getting ready for I-AP Create an app in iPhone provisioning portal and iTunes Connect Don’t submit it yet! Create I-AP products to purchase Write code with Store Kit API Test in the sandbox
    • App provisioning Create an AppID Enable it for in-app purchase
    • Create app on iTunes Connect
    • iTunes Connect warnings Enter all data as if submitting the 1.0 version of the app You’ll need icon, screenshot, description, etc. SKU and version number cannot be changed Do not submit a binary yet!
    • Store Kit
    • Store Kit iPhone APIs for in-app purchase 8 classes, 3 protocols Highly asynchronous
    • Store Kit concepts Product: an item offered for sale Payment: a request for purchase Payment transaction: a payment being managed by Store Kit Payment queue: a persistent queue of transactions in varying states (pending, purchased, failed, restored)
    • Before you start coding I-AP doesn’t work on simulator; must test on device Apps installed by Xcode run in the I-AP “sandbox” Your iTunes account won’t be charged Must use an iTunes I-AP test account
    • First step: define some products <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/ DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> ! <key>product0</key> ! <dict> ! ! <key>description</key> ! ! <string>VTM t-shirt</string> ! </dict> ! <key>product1</key> ! <dict> ! ! <key>description</key> ! ! <string>VTM hoodie</string> ! </dict> </dict> </plist>
    • Products Identified by a unique product identifier string Can be embedded in your application, or downloaded from the network
    • Turning ids into products [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; SKProductsRequest *request = [[SKProductsRequest alloc] ! ! ! ! ! initWithProductIdentifiers: ! ! ! ! ! [NSSet setWithArray:[productsPList allKeys]]]; [request setDelegate:self]; [request start];
    • SKProductsRequestDelegate - (void)productsRequest:(SKProductsRequest *)request ! didReceiveResponse:(SKProductsResponse *)response { ! NSLog (@"productsRequest response: %@", response); ! ! [products release]; ! products = [response.products retain]; ! [self.tableView reloadData]; ! [UIApplication sharedApplication].networkActivityIndicatorVisible= NO; }
    • SKProductsRequestDelegate Response includes SKProducts which matched productIds in your request Ids not yet set up in iTunes Connect fail Ids in iTunes Connect but not in your request will be absent
    • Creating with iTunes Connect
    • iTunes Connect Product Fields
    • Product Types Non-consumable (aka, “durable”) — purchase once, own forever eBooks, game levels, avatar bling Consumable — purchase, use up, purchase again Ammo, boosts, online event access Subscriptions
    • SKProduct properties productIdentifier price, priceLocale localizedTitle, localizedDescription
    • Making purchases // purchase the selected item [[SKPaymentQueue defaultQueue] addPayment: ! [SKPayment paymentWithProduct: [products objectAtIndex:indexPath.row]]];
    • Observing purchase progress [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; Calls back to paymentQueue:updatedTransacations: Transactions persist until you remove from queue with finishTransaction: Get purchases made on other devices via restoreCompletedTransactions
    • Handling purchases in-progress - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *) transactions { ! for (SKPaymentTransaction *transaction in transactions) { ! ! switch (transaction.transactionState) { ! ! ! case SKPaymentTransactionStatePurchasing: { ! ! ! ! [UIApplication sharedApplication]. networkActivityIndicatorVisible = YES; ! ! ! ! break; ! ! ! }
    • Handling purchase success case SKPaymentTransactionStatePurchased: { ! NSLog (@"SKPaymentTransactionStatePurchased"); ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [inventoryVC addProductIdentifier: transaction.payment.productIdentifier]; ! [queue finishTransaction:transaction]; ! AudioServicesPlaySystemSound (kachingSound); ! break; }
    • Handling purchase failure case SKPaymentTransactionStateFailed: { ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! NSLog (@"SKPaymentTransactionStateFailed: %@", transaction); ! [queue finishTransaction:transaction]; ! break; }
    • Handling payment restoration -[SKPaymentQueue restoreCompletedTransactions] case SKPaymentTransactionStateRestored: { ! NSLog (@"SKPaymentTransactionStateRestored"); ! [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; ! [inventoryVC addProductIdentifier: transaction.originalTransaction.payment.productIdentifier]; ! [queue finishTransaction:transaction]; ! break; }
    • Playing with purchases Completed purchases give you only a productIdentifier, not an SKProduct Your app needs some other way of identifying what has been purchased
    • Beyond Store Kit
    • So much more than just Store Kit Goods delivery Persisting purchases Audit trail Purchase restoration
    • Delivering goods Where is your product? In the bundle — unlock On a server — download
    • Persisting purchases Purchases must be available on future app launches. Where to persist? Local file system SQLite / Core Data Keychain
    • Audit Trail App communicates directly with Apple Your business has no record of this purchase But if customer has a problem, they’re calling you What do you do?
    • Purchase authentication Completed transactions have a transactionReceipt property Can be verified via Apple web service at http://buy.itunes.apple.com/verifyReceipt Your app does not use this web service…
    • You’re a web developer now! Send transactionReceipt to a web service you write Your web service sends the receipt, base64-encoded, in a JSON message to Apple If it validates, your web service records the successful transaction in its database
    • Purchase restoration Non-consumable and subscription products are expected to be purchased once and played on all a user’s devices -[SKPaymentQueue restoreCompletedTransactions] Only call in response to a user action (e.g., a “restore purchases” button)
    • GOTCHA! restoreCompletedTransactions only works for non-consumables, not subscriptions rdar://7470096 Also, no unique identifier for the iTunes user
    • Restoring subscriptions Remember deviceId on server Doesn’t restore to other devices Create a login on a server you control Ignore the problem and hope Apple doesn’t notice (they probably won’t)
    • Erica’s Restoration Scheme Neat idea from Erica Sadun: Sell a 99¢ non-consumable, hold on to its transactionId For future purchases, log purchase info plus this id on your server Restore gives you back this id. Query your server for it to get purchases
    • Beyond Store Kit: Takeaway Expect to do server-side work Certain kinds of apps will have large server-side teams Small apps may use Google App Engine or Amazon Web Services Avoid subscriptions if you can
    • In-App Purchase WINs and FAILs
    • In-App Purchase WINs Allows you to provide new content to old apps New content that pays for itself Highly resistant to piracy Some business models require I-AP
    • In-App Purchase FAILs Subscriptions are broken I-AP requires extensive server-side development You have to do almost everything yourself
    • Earning their keep? App Store I-A P Product Hosting √ Audit Trail √ Purchase UI √ Product Restoration √ (some) Purchase Storage √ Apple’s Cut 30% 30%
    • In-App Purchase and Its Discontents
    • Stanza’s Bookstore…
    • … is a bunch of websites
    • So is Amazon Kindle Store
    • In-App Purchase Isn’t Required If you already sell goods over the web, you can keep doing so iPhone App can be a rich client, not necessarily a store If you already do all the work, why give Apple 30%?
    • Running your own credit swipes PayPal API Amazon payments Others…
    • An animated comparison
    • Crunchyroll Free app Same login on iPhone, web Same videos available on iPhone, web
    • Anime Network Mobile $6.99 for 30 days, I-AP to extend, nothing free Web, iPhone memberships unrelated Fewer videos available on iPhone
    • Obvious questions If Anime Network is already processing payments and delivering goods, why are they giving Apple a 30% cut? Who would pay twice for web and iPhone versions? Why do iPhone users get less for the same price?
    • Should You Adopt I-AP? How much of this server-side commerce work are you already doing or committed to? Selling the same goods on web? Or for other devices? Can you live with Apple’s policies?
    • Good candidates for I-AP iPhone-only apps Can use keychain to share between apps Selling non-consumables Number of products is manageable Practical necessity (data plan payment)
    • Bad candidates for I-AP Products also available via web Large / infinite number of products Products not pass review Subscriptions(?)
    • Q&A
    • Thanks! Chris Adamson @invalidname Voices That Matter: iPhone Developer Conference 2010