My in-app purchases work in TestFlight without problem,but again and againg rejected in app review.
func requestItem(){
if SKPaymentQueue.canMakePayments() {
let productsRequest = SKProductsRequest(productIdentifiers: ["my.purchase.item.id"])
productsRequest.delegate = self
productsRequest.start()
} else{
//show UI
self.showAlertWith("", message: "Payment is not possible", buttonTitle: "ok", style: .alert) { (alert) in
}
}
}
//SKProductsRequestDelegate
public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
let products = response.products
if(products.count>0)
{
let product = products.first
if (product != nil){
let payment = SKPayment(product: product!)
SKPaymentQueue.default().add(payment)
} else {
//show UI
self.showAlertWith("", message: "purchase item empty", buttonTitle: "ok", style: .alert) { (alert) in
}
}
}
else
{
//show UI
self.showAlertWith("", message: "purchase item empty", buttonTitle: "ok", style: .alert) { (alert) in
}
}
}
//SKProductsRequestDelegate
public func request(_ request: SKRequest, didFailWithError error: Error) {
//show UI
self.showAlertWith("", message: "skrequest reqeust error", buttonTitle: "ok", style: .alert) { (alert) in
}
}
This code workd in xcode and testflight, but it didn't work when reviewing the app.(twice rejected same reason)
I have already checked the "waiting for review" status and banking and tax related content before submitting the app.
I think SKProductsResponse and didFailWithError both did not work when SKProductsRequest is working, so ui does not appear.
Can you tell me how to solve it?
At the least you need to add in the productRequest delegate methods in iOS11:
public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse)
dispatch_async(dispatch_get_main_queue(), ^{
// your code here
});
//SKProductsRequestDelegate
public func request(_ request: SKRequest, didFailWithError error: Error) {
dispatch_async(dispatch_get_main_queue(), ^{
// your code here
} );
}