本文介绍了如何为我的IAP集成Touch ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的IAP有以下代码,该代码可以成功运行,但不支持想要使用Touch ID购买的用户。我需要添加到我的removeAdsButton方法以支持此功能吗?如果我没有添加任何东西来支持Touch ID,交易是否仍会成功处理?
I have the following code for my IAP, which works successfully, but doesn't support those who want to purchase with Touch ID. What do I need to add to my removeAdsButton method to support this? If I don't add anything to support Touch ID, will the transaction still process successfully?
- (void)removeAdsButton {
if([SKPaymentQueue canMakePayments]){
SKProductsRequest *productsRequest = [[SKProductsRequest alloc]
initWithProductIdentifiers:[NSSet setWithObject:kRemoveAdsProductIdentifier]];
productsRequest.delegate = self;
[productsRequest start];
}
else{
}
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *validProduct = nil;
int count = (int)[response.products count];
if(count > 0){
validProduct = [response.products objectAtIndex:0];
[self purchase:validProduct];
}
else if(!validProduct){
}
}
- (void)purchase:(SKProduct *)product{
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{
for(SKPaymentTransaction *transaction in queue.transactions){
if(transaction.transactionState == SKPaymentTransactionStateRestored){
[self doRemoveAds];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
}
}
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for(SKPaymentTransaction *transaction in transactions){
switch(transaction.transactionState){
case SKPaymentTransactionStateDeferred:
break;
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[self doRemoveAds];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if(transaction.error.code == SKErrorPaymentCancelled){
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
break;
}
}
}
- (void)restorePurchasesButton {
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
- (void)doRemoveAds{
//Does my ad removal stuff.
}
推荐答案
请关注主题。希望如此会帮助你。
Please follow https://discussions.apple.com/thread/5349382?tstart=0 thread .Hope this will help you.
这篇关于如何为我的IAP集成Touch ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!