我剛添加了一個應用程序內購買到我的應用程序。 當用戶點擊「購買」按鈕並且交易結束時,「購買」按鈕被替換爲另一個按鈕以訪問新功能。 但每次我回到那個頁面,或者我關閉並再次打開應用程序時,再次出現「購買」按鈕。 如果用戶購買了新內容,我該怎麼做才能始終保持新按鈕? 這裏是我的代碼:In App Purchase:SKPaymentTransactionStatePurchased
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(myaction)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"mytitle" forState:UIControlStateNormal];
button.frame = CGRectMake(156.0, 248.0, 129.0, 36.0);
[self.view addSubview:button];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"Errorr");
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
}
}