In App Purchases Tutorial for iOS

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

iOS 5.1

Postby grivina » Wed Mar 14, 2012 10:44 pm

Hi, thanks for useful tutorial!

It works great for me on a device with iOS 5.0 and in the simulators 5.0 and 5.1.
But on a device with 5.1 I can't receive the information about products.
Although a count of products shows the right value.
As result no one of products loads.

Have anybody had a similar problem? Any thoughts? Are there changes with in-app in iOS 5.1?

Upd: I found odd thing. "response.products" returns null in 5.1
Can you please help with it?
grivina
n00b
 
Posts: 1
Joined: Wed Mar 14, 2012 10:34 pm
Has thanked: 0 time
Been thanked: 0 time

Re: iOS 5.1

Postby ddaddy » Fri Mar 16, 2012 12:02 pm

grivina wrote:Hi, thanks for useful tutorial!

It works great for me on a device with iOS 5.0 and in the simulators 5.0 and 5.1.
But on a device with 5.1 I can't receive the information about products.
Although a count of products shows the right value.
As result no one of products loads.

Have anybody had a similar problem? Any thoughts? Are there changes with in-app in iOS 5.1?

Upd: I found odd thing. "response.products" returns null in 5.1
Can you please help with it?

It's working fine for me on 5.1
ddaddy
Baby Hacker
 
Posts: 5
Joined: Sun Mar 11, 2012 7:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby ddaddy » Fri Mar 16, 2012 12:26 pm

However... I am having a problem with the buyProductIdentifier code
[SKPayment paymentWithProductIdentifier:
has been replaced with
[SKPayment paymentWithProduct:

How do I pass it the product when we have the productIdentifier?

Thanks

EDIT: I think i've got it. On the buy button press, just send the product and not product.productIdentifier

Teach me to complete the whole thing next time!
ddaddy
Baby Hacker
 
Posts: 5
Joined: Sun Mar 11, 2012 7:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby deepalip5 » Thu Mar 22, 2012 12:34 pm

Thanks a Lot Ray.. have finished and published my first iPhone App ..Very Proud of it though it has a few bugs :D
deepalip5
n00b
 
Posts: 1
Joined: Thu Mar 22, 2012 12:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby Oral B » Sun Mar 25, 2012 1:47 am

When I run the sample project, the fields are all blank. Has anyone figured out a fix to this yet?
Oral B
n00b
 
Posts: 1
Joined: Sun Mar 25, 2012 1:46 am
Has thanked: 0 time
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby mijator » Sun Apr 01, 2012 3:18 pm

Nice to know that you don't have to upload a binary in order to test, but is there an updated version of:

SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier];

It complains that it's deprecated and when I try to replace it with "paymentWithProduct:" I don't know what follows the ":" so get a types mismatch error.

Also, any suggestions for how to implement using a Cocos2d page instead of an interface builder view (.xib) would be much appreciated!
User avatar
mijator
Hacker
 
Posts: 15
Joined: Sun Dec 18, 2011 5:42 pm
Location: Canada
Has thanked: 3 times
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby Hollance » Sun Apr 01, 2012 11:10 pm

mijator wrote:when I try to replace it with "paymentWithProduct:" I don't know what follows the ":" so get a types mismatch error.

It says "paymentWithProduct:", so you can either look up the name of this method in the documentation for SKPayment, or even guess at it.

You'll have to put an SKProduct object after the :, and you can get an SKProduct from the SKProductsResponse object that you got after you checked the product identifiers with the App Store.
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4614
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 611 times

Re: Introduction to In-App Purchases

Postby itsme.manish » Tue Apr 03, 2012 6:20 am

Thanks Ray for a wonderful tutorial.
Although I have one question, on successfully purchasing a product I see that we are storing the product id in NSUserDefaults. Now what if after purchasing a product user has to delete the app and reinstall, in that case the NSUserDefaults will be cleared and we will lose all in-app purchase info of the user.

So I was wondering is there any way we can fetch the user in app purchase info from App store. We can then fetch the info every time the app launches. Or we'll have to do it on our server maintaining the in app purchases status for each user.

Thanks
itsme.manish
n00b
 
Posts: 3
Joined: Tue Apr 03, 2012 6:16 am
Has thanked: 0 time
Been thanked: 0 time

Re: Introduction to In-App Purchases

Postby Hollance » Wed Apr 04, 2012 4:26 am

itsme.manish wrote:So I was wondering is there any way we can fetch the user in app purchase info from App store. We can then fetch the info every time the app launches. Or we'll have to do it on our server maintaining the in app purchases status for each user.

You can ask the App Store server to restore the user's previous purchases. This will then send your app the proper notifications, just as if the purchase was made the first time.

However, you shouldn't do that every time the app starts. Instead, make a Restore Purchases button that does this when the user taps it.

You can also store information about the user's purchases on iCloud.
Like card games? Play my new game Mahjong Cards for iPad.
User avatar
Hollance
Team Member
iOS Tutorial Team Member
 
Posts: 4614
Joined: Wed Mar 09, 2011 8:33 pm
Location: The Netherlands
Has thanked: 0 time
Been thanked: 611 times

Re: Introduction to In-App Purchases

Postby itsme.manish » Wed Apr 04, 2012 8:13 am

Thanks Hollance for your reply.

I am now stuck at something I have seen many other user's are also stuck at. I tried implementing in app purchases in my app, set up everything as mentioned in the tutorial, but SKProductsRequest returns empty product list. I have checked that my productIDs have correct prefix as my bundle identifier.
I also tried running the sample code, it also returns me an empty list.

Any idea what could be the issue here?
itsme.manish
n00b
 
Posts: 3
Joined: Tue Apr 03, 2012 6:16 am
Has thanked: 0 time
Been thanked: 0 time

PreviousNext

Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests