Reputation: 1686
iam using In App purchase in my project.Currently things are working purchase are happening from sandbox.But i found one issue regarding the product identifiers.Now iam hard coding the product identifier like below. Am storing the product identifier in a plist (ProductId.plist)manually (please refer image)
#import "RageIAPHelper.h"
@implementation RageIAPHelper
+ (RageIAPHelper *)sharedInstance {
static dispatch_once_t once;
static RageIAPHelper * sharedInstance;
dispatch_once(&once, ^{
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"ProductId" ofType:@"plist"];
NSArray * contentArray = [NSArray arrayWithContentsOfFile:plistPath];
NSLog(@"content aray:%@",contentArray);
NSSet * productIdentifiers= [NSSet setWithArray:contentArray];
sharedInstance = [[self alloc] initWithProductIdentifiers:productIdentifiers];
});
return sharedInstance;
}
@end
//CODE FROM RAY WENDERLICH IN APP PURCHASE TUTTORIAL
Problem is now am not able to take the product identifiers dynamically from the iTunes Store. So how can i get Product id from itunes store instead of hard coding in plist??? please help
Upvotes: 2
Views: 2183
Reputation: 156
You cannot get product ids from AppStore IN APP, but you can generate plist of product ids automatically.
Here's steps:
Fetch metadata.xml
by using transporter:
iTMSTransporter -m lookupMetadata \
-u [username] \
-p [password] \
-vendor_id [vendor id] \
-subitemtype InAppPurchase \
-destination [local destination]
Transform metadata.xml
into product_ids.plist
:
# /usr/bin/sh
# usage: [this script] [path/to/metadata.xml] > [path/to/product_ids.plist]
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"'
echo ' "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
echo '<plist version="1.0">'
echo '<array>'
sed -n 's/.*<product_id>\(.*\)<.*/ \<string\>\1\<\/string\>/p' $1
echo '</array>'
echo '</plist>'
You can integrate those shell script into your production deploy script, or you can write your own script base on this concept.
Upvotes: 0
Reputation: 8538
You can't get those identifiers from the AppStore!. If you really need to deliver those product identifiers dynamically, you should put a file with the list of identifiers in a visible server.
Please read the section Feature Delivery in Apple documentation. You should use the "Server Product Model".
The old link that I wrote is outdated. The current doc is more explicit
Upvotes: 2
Reputation: 3813
You can do following to get product data.
NSSet *productIdentifiers = [NSSet setWithObject:@"com.****.******"];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];
This delegate will get call which will get product information you required
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
Upvotes: 2