gpt4 book ai didi

swift - IAP-Swift 3.0

转载 作者:行者123 更新时间:2023-11-28 08:17:09 24 4
gpt4 key购买 nike

我想为我的 Swift 应用程序执行 IAP,每当我尝试通过代码连接 intunes 时,我的 xcode 中缺少授权,请参阅附件。

这是我连接 itunes connect 的代码。

func loadStoreProducts(){


if (SKPaymentQueue.canMakePayments()){
KVNProgress.show(withStatus: "Loading payment options")
let productsRequest:SKProductsRequest = SKProductsRequest(productIdentifiers: Set([productID]));
productsRequest.delegate = self;
productsRequest.start();
}else{
AppDelegate.getAppDelegate().showMessage("Your Apple account doesn't allow payments, you cannot have a JustAskMe subscription.")
}
}

func restoreTransactions(){
SKPaymentQueue.default().restoreCompletedTransactions()
}

func buyMembership(product:SKProduct){
let payment = SKPayment(product: product)
SKPaymentQueue.default().add(payment);
}

func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {

DispatchQueue.main.async(){
KVNProgress.dismiss()
}


if (!response.products.isEmpty) {

let validProduct: SKProduct = response.products[0] as SKProduct

if (validProduct.productIdentifier == self.productID) {
print(validProduct.localizedTitle)
print(validProduct.localizedDescription)
print(validProduct.price)
buyMembership(product: validProduct);
} else {
// got a product that wasn't the one we asked for?
print("Invalid product found: \(validProduct.productIdentifier)")
}
} else {
AppDelegate.getAppDelegate().showMessage("Problems processing your payment, please try again.")
}
}

func request(_ request: SKRequest, didFailWithError error: Error) {

DispatchQueue.main.async(){
KVNProgress.dismiss()
}
// notify the user
AppDelegate.getAppDelegate().showMessage("Problems processing your payment, please try again.")
//log the issue.
print(error.localizedDescription)

}


func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
DispatchQueue.main.async(){
KVNProgress.dismiss()
}

for transaction:AnyObject in queue.transactions
{
let trans : SKPaymentTransaction = transaction as! SKPaymentTransaction
let identifier : NSString = trans.payment.productIdentifier as NSString
print(identifier)
}

}

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
DispatchQueue.main.async(){
KVNProgress.dismiss()
}

}

func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) {
DispatchQueue.main.async(){
KVNProgress.dismiss()
}
// notify the user
AppDelegate.getAppDelegate().showMessage("Problems loading your previous purchases, please try again.")
//log the issue.
print(error.localizedDescription)
}

enter image description here

最佳答案

您是否在 Capabilities Pane 中打开了应用内购买? Xcode 的?

关于swift - IAP-Swift 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42272376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com