在我的應用程序中,我設置了兩個不同的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