在我的应用程序中,我设置了两个不同的In App Purchase ID,可以说;Multiple In App Purchase - 如何在购买时设置不同的ID
com.myapp.purchase1 com.myapp.purchase2
的升级被设定为2个不同的IBActions与alert.tag用于每个产品的升级之间者区分。 但是,这部分工作正常。
购买1 =删除广告 购买2 =增加了更多的色彩
如果我购买,购买2,它的工作原理 - 广告仍然存在。 如果我购买了购买1,它将删除广告并解锁颜色 - 这是错误的。
购买2与此处的NSUSerDefaults链接;
-(void)randImage
{
currentIndex = (currentIndex+1) % ([[NSUserDefaults standardUserDefaults] boolForKey:@"com.myapp.purchase2"] ? 32 : 16);
UIImage *myImage = [UIImage imageNamed:[NSString stringWithFormat:@"f%d.png",currentIndex +1]];
[ColorsImage setImage:myImage];
}
这是MKStoreManager.h
#define kConsumableBaseFeatureId @"com.myapp.colorsapp"
#define kFeatureAId @"com.myapp.purchase1"
#define kFeatureBId @"com.myapp.purchase2"
当升级工艺制成,这是代码,我怀疑这就是问题所在区域,但可别以为我会怎么解决?我在购买后打电话给setBool,即使在purchase1时,我也会这样称呼它;我怎样才能在purchase2订购时致电?
-(void) provideContent: (NSString*) productIdentifier
forReceipt:(NSData*) receiptData
{
if(ownServer != nil && SERVER_PRODUCT_MODEL)
{
// ping server and get response before serializing the product
// this is a blocking call to post receipt data to your server
// it should normally take a couple of seconds on a good 3G connection
if(![self verifyReceipt:receiptData]) return;
}
NSRange range = [productIdentifier rangeOfString:kConsumableBaseFeatureId];
NSString *countText = [productIdentifier substringFromIndex:range.location+[kConsumableBaseFeatureId length]];
int quantityPurchased = [countText intValue];
if(quantityPurchased != 0)
{
int oldCount = [[NSUserDefaults standardUserDefaults] integerForKey:productIdentifier];
oldCount += quantityPurchased;
[[NSUserDefaults standardUserDefaults] setInteger:oldCount forKey:productIdentifier];
}
else
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:productIdentifier];
}
[[NSUserDefaults standardUserDefaults] synchronize];
if([_delegate respondsToSelector:@selector(productPurchased:)])
[_delegate productPurchased:productIdentifier];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"com.myapp.purchase2"];
[[NSUserDefaults standardUserDefaults] synchronize];
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Upgrades" message:@"Successfully Purchased" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
这听起来像是一个经典的案例忘记添加一个“休息”在IBAction开关案例 – Stavash 2013-05-03 20:48:28