3

I am trying inapp purchase.

I am unable to implement following method :

SKPayment *payment = [SKPayment paymentWithProduct:`SKProduct`];

But here I dont know from where I will get this SKProduct's object or which parameter I have to pass here ?

Any suggestion?

Maulik
  • 19,348
  • 14
  • 82
  • 137
Devang
  • 11,258
  • 13
  • 62
  • 100

2 Answers2

7

Assuming you have a valid product registered on itunesconnect, and you know the product's identifier, you could do something like this:

SKMutablePayment *payment = [[[SKMutablePayment alloc] init] autorelease];
payment.productIdentifier = @"myvalidproductidentifier";
payment.quantity = <quantity>;
[[SKPaymentQueue defaultQueue] addPayment:payment];

Observe that you will need a valid product identifier otherwise the payment queue will return an error, usually: "Cannot connect to iTunes store".

Jeremy
  • 8,902
  • 2
  • 36
  • 44
0

I highly recommend using MKStoreKit by Mugunth Kumar

It will massively simplify your code base and includes clear instructions for handling all type of products (consumables etc)

Nik Burns
  • 3,363
  • 2
  • 29
  • 37