Purchasing a Product

In the previous section, we learned how to add products to your app. Without the ability to purchase these products, our implementation is only partially complete. In this section, we look at how to handle purchasing products directly through your app.

Purchasing Code

The first thing that we need to do is make our store's view controller class conform to the SKPaymentTransactionObserver protocol. After that is done, we modify our existing viewDidLoad method. We add ourselves as a new transaction observer. Additionally, we perform a test to make sure that we can make payments on this device, and if not, display a UIAlert to inform the user.

- (void)viewDidLoad {     [super viewDidLoad];     [[SKPaymentQueue defaultQueue] ...

Get Beginning iOS Game Center and Game Kit: For iPhone, iPad, and iPod touch now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.