-4

I have the price of my item which I am going to purchase , coming from server.That means i going to get the price of my item on runtime.How can i achieve it on run time.

Nitin
  • 1,383
  • 10
  • 19
  • http://stackoverflow.com/questions/11315769/in-app-purchase-dynamically-add-non-consumable-items – iPatel Apr 23 '14 at 06:51
  • you mean you want prices for you in-app purchase runtime right? – ChintaN -Maddy- Ramani Apr 23 '14 at 06:54
  • @ChinttuRoxeNRamani I have prices for items at run time how can i achieve this in my application? – Nitin Apr 23 '14 at 07:01
  • the price information is contained in the dictionary that u get when you query the app store. You should read the in app purchase guide by apple. This question lacks research. – Pochi Apr 23 '14 at 07:02

2 Answers2

-1
[[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
    if (success)
    {
        NSMutableArray *arrTemp = [[NSMutableArray alloc]init];
        for (SKProduct *Sss in products)
        {
             NSString *string = Sss.productIdentifier;//@"hello bla bla";

             NSMutableDictionary *dictprod = [NSMutableDictionary dictionary];
             [dictprod setObject:Sss.productIdentifier forKey:@"ProductIdentifier"];
             [dictprod setObject:Sss.price forKey:@"ProductPrice"];
             [dictprod setObject:Sss.localizedTitle forKey:@"ProductTitle"];
             [arrTemp addObject:dictprod];
        }
    }
}

NSLog(@"%@", arrTemp);

Please use Valid Provisioning profile. this array of products will give you all in app purchases with details which you have added in you app. Try this code maybe this will help you.

ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
  • I have prices for items dynamically and these values are coming from a server. What I need to do is to use in app purchases to purchases the item with the corresponding price which coming from server – Nitin Apr 23 '14 at 07:05
  • If you want to purchase item then you have to just pass `productidentifier` and apple will recognize your product. – ChintaN -Maddy- Ramani Apr 23 '14 at 07:08
-2

Generally speaking, you should not trust your own server for the price, but trust Apple's IAP servers. At least, the one who charge your users is Apple, not your server.

The standard flow of an IAP (of your situation) would be:

  1. Get the item ids list (only) from your server. Your server can decide what items can be purchased by client, and just returns the ones available.
  2. When your app get the list, you should contact with Apple's server to get the detail information with these ids. Use SKProductsRequest to do this.
  3. Apple will return an array contains SKProduct objects to your app. Now you can retrieve the price you set in iTunes Connect by property price or priceLocale.

You may want to refer to Apple's IAP guide for more detail information

onevcat
  • 4,591
  • 1
  • 25
  • 31