プロジェクトにアプリ内購入を実装しました。実装はうまくいきましたが、応答を保存するのに問題があります。
ボタンのロックを解除し、アプリ内購入を行うと、ボタンのロックが解除され、応答が true になります。
しかし、このクラスの元のクラスに戻り、このクラスに再びジャンプすると、応答を保存できないため、ボタンが再びロックされました。
私はこれをやっています:
.h file
bool isPurchased;
-(void) successfulPurchase:(EBPurchase*)ebp restored:(bool)isRestore identifier:(NSString*)productId receipt:(NSData*)transactionReceipt
{
NSLog(@"ViewController successfulPurchase");
// Purchase or Restore request was successful, so...
// 1 - Unlock the purchased content for your new customer!
// 2 - Notify the user that the transaction was successful.
if (!isPurchased)
{
// If paid status has not yet changed, then do so now. Checking
// isPurchased boolean ensures user is only shown Thank You message
// once even if multiple transaction receipts are successfully
// processed (such as past subscription renewals).
isPurchased = YES;
if([[[NSUserDefaults standardUserDefaults] objectForKey:@"isPurchased"] isEqualToString:@"true"]){
isPurchased = YES;
// do something
}
else{
isPurchased = NO;
//isFailed = NO;
// do something
}
//-------------------------------------
// 1 - Unlock the purchased content and update the app's stored settings.
//-------------------------------------
// 2 - Notify the user that the transaction was successful.
NSString *alertMessage;
if (isRestore) {
// This was a Restore request.
alertMessage = @"Your purchase was restored and the Game Levels Pack is now unlocked for your enjoyment!";
} else {
// This was a Purchase request.
alertMessage = @"Your purchase was successful and the Game Levels Pack is now unlocked for your enjoyment!";
// if (my_unlock_button == TRUE) {
buyButton.hidden=YES; // These are the buttons I unlocked
buybutton1.hidden=YES; // These are the buttons I unlocked
//}
}
UIAlertView *updatedAlert = [[UIAlertView alloc] initWithTitle:@"Thank You!" message:alertMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[updatedAlert show];
[updatedAlert release];
}
}
応答を確認できるように、応答を保存して取得する方法は?
専門家からのアイデアや提案は大歓迎です。