# In-App Purchase Tutorial: Getting Started

**URL:** <https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 31, 2016, 1:02pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664 "2016-03-31T13:02:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anros](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/anros/32/39532_2.png) [@anros](https://forums.kodeco.com/u/anros)\
**Post date:** [March 31, 2016, 1:02pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/1 "2016-03-31T13:02:09Z")

</div>

Learn how to grow app revenue in this in-app purchase tutorial by allowing users to purchase or unlock content or features. Updated for iOS 9 and Swift 2.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1244-in-app-purchase-tutorial-getting-started](https://www.raywenderlich.com/1244-in-app-purchase-tutorial-getting-started)

---

<div class="post-metadata">

**Author:** ![joebenton](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/joebenton/32/17419_2.png) [@joebenton](https://forums.kodeco.com/u/joebenton)\
**Post date:** [April 4, 2016, 10:06am UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/3 "2016-04-04T10:06:29Z")

</div>

Just to add, in your InAppRageDemo Final IAPHelper.swift on like 161 you get a compile error in iOS 9.3 and need to change this code:

`if transaction.error.code != SKErrorPaymentCancelled {`

to this, where they have changed the SDK of the SKErrorCode:

`if transaction.error!.code != SKErrorCode.PaymentCancelled.rawValue {`

Other than that, great tutorial thanks.

([http://stackoverflow.com/questions/36156724/unresolved-identifier-skerrorpaymentcancelled](http://stackoverflow.com/questions/36156724/unresolved-identifier-skerrorpaymentcancelled))

---

<div class="post-metadata">

**Author:** ![vedran8](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/vedran8/32/18032_2.png) [@vedran8](https://forums.kodeco.com/u/vedran8)\
**Post date:** [April 4, 2016, 8:37pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/4 "2016-04-04T20:37:02Z")

</div>

Well it would be nice if you can integrate also consumable products for ex: adding some coins to label … Tnx

---

<div class="post-metadata">

**Author:** ![kool\_rob](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/kool_rob/32/26741_2.png) [@kool\_rob](https://forums.kodeco.com/u/kool_rob)\
**Post date:** [April 9, 2016, 10:14pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/5 "2016-04-09T22:14:53Z")

</div>

Great guide for Swift but was wondering if there was any way to get this new Xcode 7.3 iOS 9 guide with Objective-C files. I’m sure I can’t be the only one with old projects that needs an updated IAP 🙂  
Thanks

---

<div class="post-metadata">

**Author:** ![goojiu](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/goojiu/32/30873_2.png) [@goojiu](https://forums.kodeco.com/u/goojiu)\
**Post date:** [April 18, 2016, 4:37pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/6 "2016-04-18T16:37:27Z")

</div>

Hello,

I found that sandbox purchases work, but when I sign into my personal account to make a purchase, I get the error:

Error Domain=SKErrorDomain Code=0 “Cannot connect to iTunes Store” UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store

I found that restarting my iPhone corrects this behavior. Do you know if signing in and out of the iTunes app store breaks connectivity to the iTunes store?

---

<div class="post-metadata">

**Author:** ![fbara](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fbara/32/88428_2.png) [@fbara](https://forums.kodeco.com/u/fbara)\
**Post date:** [April 19, 2016, 12:19pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/7 "2016-04-19T12:19:35Z")

</div>

The original tutorial from a few years ago covers how to do this in Obj-c. Even though it’s a few years old, the instructions are still valid. I used them to create the IAP for 2 of my apps.

---

<div class="post-metadata">

**Author:** ![birdiboy](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/birdiboy/32/31493_2.png) [@birdiboy](https://forums.kodeco.com/u/birdiboy)\
**Post date:** [April 27, 2016, 10:49am UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/8 "2016-04-27T10:49:11Z")

</div>

App crashes when I click on Buy button . I have followed all the steps mentioned in the tutorial without any mistake. Same error in the final downloaded code.  
Please help me resolve the issue.  
[Rage.ProductCell ProductCell.buyButtonTapped(_:):]: unrecognized selector sent to instance 0x162b1c00  
2016-04-27 16:04:41.336 Rage[534:112914] \*\*\* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '-[Rage.ProductCell ProductCell.buyButtonTapped(_:):]: unrecognized selector sent to instance 0x162b1c00’  
\*\*\* First throw call stack:  
(0x2202010b 0x217c6e17 0x22025925 0x22023559 0x21f53c08 0x261946cd 0x26194659 0x2617c64f 0x26193fb5 0x2614e275 0x2618ce21 0x2618c5d3 0x2615d2f9 0x2615b98b 0x21fe368f 0x21fe327d 0x21fe15eb 0x21f34bf9 0x21f349e5 0x23180ac9 0x261c4ba1 0xd7f4c 0x21be3873)  
libc++abi.dylib: terminating with uncaught exception of type NSException

---

<div class="post-metadata">

**Author:** ![roselle](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/roselle/32/31968_2.png) [@roselle](https://forums.kodeco.com/u/roselle)\
**Post date:** [May 4, 2016, 1:48am UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/9 "2016-05-04T01:48:35Z")

</div>

I would check your outlets and actions in Interface Builder. Select the ViewController that contains your button in the UINavigator. Then go to the the connections inspector in the Utility Pane. Check that the connections are hooked up properly and delete any that shouldn’t be there. Hovering over the connections highlights their associated views and can be helpful in sorting it out. I hope this helps!

---

<div class="post-metadata">

**Author:** ![leland](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@leland](https://forums.kodeco.com/u/leland)\
**Post date:** [May 5, 2016, 8:48pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/10 "2016-05-05T20:48:10Z")

</div>

Is it possible to A) use this method to purchase an Audio track and then play it with in the app? Down load it almost as a local bundle file? B) can the above Swift code be used in an existing objective-c app?

---

<div class="post-metadata">

**Author:** ![sergeydi](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sergeydi/32/81494_2.png) [@sergeydi](https://forums.kodeco.com/u/sergeydi)\
**Post date:** [May 29, 2016, 12:23pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/11 "2016-05-29T12:23:53Z")

</div>

Hi,

I am working on iOS application with media content, purchased by $1 per any item. I want to give for every new user discount: first any five items by $0 per item. How to do this?

---

<div class="post-metadata">

**Author:** ![nontomatic](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nontomatic/32/81494_2.png) [@nontomatic](https://forums.kodeco.com/u/nontomatic)\
**Post date:** [May 31, 2016, 1:23pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/12 "2016-05-31T13:23:31Z")

</div>

This whole process is extremely frustrating. The in app purchase won’t show up in the app which may be related to not having uploaded a screenshot for the in app purchase (of which there is no mentioning in this tutorial). So I did that and it still won’t show up. The status in the list of In-AppPurchases in iTunes Connect says: “Ready to submit.” with a yellow light. I thought I had submitted it already, what should I do?

---

<div class="post-metadata">

**Author:** ![jayjac](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jayjac/32/81494_2.png) [@jayjac](https://forums.kodeco.com/u/jayjac)\
**Post date:** [June 11, 2016, 2:47pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/13 "2016-06-11T14:47:31Z")

</div>

It seems like the product identifier no longer contains the bundle ID as a prefix. So in the example of this tutorial I had to use “GirlfriendOfDrummerRage” and not “com.mybundle.Rage.GirlfriendOfDrummer”  
Is this a new Apple naming scheme or did I miss out on something ?

---

<div class="post-metadata">

**Author:** ![jayjac](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jayjac/32/81494_2.png) [@jayjac](https://forums.kodeco.com/u/jayjac)\
**Post date:** [June 11, 2016, 2:52pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/14 "2016-06-11T14:52:13Z")

</div>

I had the same issue, then I went in “RageProducts.swift” and in the RageProducts struct, I cleared the Prefix (private static let Prefix = “”)  
and that solved the issue. Hope that’ll help you

---

<div class="post-metadata">

**Author:** ![yvesbastos](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/yvesbastos/32/37005_2.png) [@yvesbastos](https://forums.kodeco.com/u/yvesbastos)\
**Post date:** [July 15, 2016, 2:04am UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/15 "2016-07-15T02:04:26Z")

</div>

Your tutorial helped me a lot - thanks for it!  
However, this whole process has been incredibly frustrating. I’ve followed your exact steps (and I’m testing it on a real device, not the Simulator). However, after my first purchase (my app offers 3 options), the paymentQueue\_updatedTransactions function is being called repeatedly, for no reason. For example, if the [transactions] array has 3 items, the whole function is being called three times. Anyone know why this could be happening?

---

<div class="post-metadata">

**Author:** ![sh10151](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sh10151/32/37831_2.png) [@sh10151](https://forums.kodeco.com/u/sh10151)\
**Post date:** [July 28, 2016, 1:36am UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/16 "2016-07-28T01:36:50Z")

</div>

Great tutorial, thanks.  
Two questions:

1.) Is there a way to sort the order of the products that come back from Apple? Do they show up in the app in the same order the are listed in iTunes Connect?

2.) Is there a way to fire this code before this Table View is loaded? My IAP page is a tab, so the user selects the tab, and then it takes a few seconds for the products to load. Is there a way to get this to run before the person loads this view? So that by the time they select the tab the products are already there?

Thanks again!

---

<div class="post-metadata">

**Author:** ![bhandarip](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bhandarip/32/38795_2.png) [@bhandarip](https://forums.kodeco.com/u/bhandarip)\
**Post date:** [August 12, 2016, 6:04pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/17 "2016-08-12T18:04:06Z")

</div>

Thanks for the great tutorial. I had same issue of not showing up the products listing. We don’t need to add prefix in RageProducts class when defining the in app purchase product id. Once again thank you for the tutorial.

---

<div class="post-metadata">

**Author:** ![jsbotts73](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jsbotts73/32/87877_2.png) [@jsbotts73](https://forums.kodeco.com/u/jsbotts73)\
**Post date:** [August 14, 2016, 4:54pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/18 "2016-08-14T16:54:21Z")

</div>

In RageProducts.swift you mention the line:  
private static let productIdentifiers: Set = [RageProducts.GirlfriendOfDrummerRage]  
but in the file created by Apple the line is:  
private static let productIdentifiers: Set = [RageProducts.GirlfriendOfDrummerRage]

Then in the file IAPHelper.swift when I add the line:  
private let productIdentifiers: Set,  
I get an error "Reference to generic type ‘Set’ requires argument. I am getting numerous errors when entering lines  
into the IAPHelper file.

---

<div class="post-metadata">

**Author:** ![jsbotts73](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jsbotts73/32/87877_2.png) [@jsbotts73](https://forums.kodeco.com/u/jsbotts73)\
**Post date:** [August 14, 2016, 5:06pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/19 "2016-08-14T17:06:37Z")

</div>

Error: the line created by Apple is:

private static let productIdentifiers: Set = [RageProducts.GirlfriendOfDrummerRage]

---

<div class="post-metadata">

**Author:** ![jsbotts73](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jsbotts73/32/87877_2.png) [@jsbotts73](https://forums.kodeco.com/u/jsbotts73)\
**Post date:** [August 14, 2016, 5:10pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/20 "2016-08-14T17:10:40Z")

</div>

Error:  
Cannot cut and paste and then delete part of a line. The line produced by Apple is:

private static let productionIdentifiers: Set = [RageProducts.GirlFriendOfDrummerRage]

Sorry for the errors in submitting this. I am new to a forum.

---

<div class="post-metadata">

**Author:** ![raghuram](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/raghuram/32/39336_2.png) [@raghuram](https://forums.kodeco.com/u/raghuram)\
**Post date:** [August 21, 2016, 2:08pm UTC](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664/21 "2016-08-21T14:08:53Z")

</div>

Your tutorial help me a lot.I gone through the In-App purchase tutorial.Everuthing is ok according to my project i want to impement the buy using UIbutton. if i add this RageProducts.store.buyProduct(product)  
inside a Uibutton action i am not getting Skproduct from the product list…Wating for your reply thank you…!

[Next page](https://forums.kodeco.com/t/in-app-purchase-tutorial-getting-started/11664.md?page=2)
