我有一个我正在创建的应用广告。我如何进行应用内购买以删除iAd。我已经选择了应用内购买,但就是这样。我不确定是否有一些编码ID必须做
答案 0 :(得分:1)
您必须执行以下操作:
购买成功完成后,在bool
中存储NSUserDefaults
值,如下所示:
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
[[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"isPurchased"];
[[NSUserDefaults standardUserDefaults]synchronize];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
NSLog(@"Transaction Failed");
default:break;
}
}
}
然后在您将广告添加到视图的代码部分:
if ([[NSUserDefaults standardUserDefaults]boolForKey:@"isPurchased"] != YES) {
// Code to show the Ad's
}
就是这样。