I have been google this issue for couple hours. I have attempted something like:
The only thing I'm not sure is that I haven't fill Banking and Tax things in my iTunes connect. Actually, I just filled the Banking info, but it needs 24 hours to update.
My codes look like this
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Set IAPS
if(SKPaymentQueue.canMakePayments()) {
println("IAP is enabled, loading")
var productID:NSSet = NSSet(objects: "ProductID")
var request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as Set<NSObject>)
request.delegate = self
request.start()
} else {
println("please enable IAPS")
}
}
func productsRequest(request: SKProductsRequest!, didReceiveResponse response: SKProductsResponse!) {
println("product request")
var myProduct = response.products
for product in myProduct {
println("product added")
println(product.productIdentifier)
println(product.localizedTitle)
println(product.localizedDescription)
println(product.price)
list.append(product as! SKProduct)
}
}
This code is from a example, it was work very well in my simulator. But when I replace the ProductID with my own productID (of course bundleID as well), the SKProductsrequest become return nothing.
I have no idea why, hope some one can help me. Thx!
I was having this issue all week - no matter what I tried code wise and tweaking my build & provisioning settings, I got no products back.
What finally fixed it for me was changing the bundle id for my app xcode from company.appname
to com.company.appname
. Meanwhile you want to refer to your in-app purchase IDs withthe format com.company.appname.thingforpurchase1
etc.
In trying to solve this, I re-did the process of setting up automatic provisioning within the project and build settings & I re-added my developer account to xcode again. After doing this, the above syntax worked for me. Note that on itunes connect, my apps' bundle ID is still specified as just company.appname
, but for some reason in xcode it needs the com.
at the start too.
There is one other thing i've had to do differently with Swift 2.0 vs Swift 1.x - the compiler will no longer accept the product id's are no longer an NSSet
- instead the request seems to want identifiers be given as a Set<String>
- see this in the example below.
Note this solution was developed with and worked in swift 2.0 and xcode 7 beta.
Ex:
func requestProductInfo() {
print("about to fetch product info")
if SKPaymentQueue.canMakePayments() {
let request = SKProductsRequest(productIdentifiers:
Set(productIDs))
let productIdentifiers: NSSet = NSSet(array: productIDs) // NSset might need to be mutable
let productRequest : SKProductsRequest = SKProductsRequest(productIdentifiers: productIdentifiers as! Set<String>)
//we set our class as its delegate (so we can handle the response)& trigger the request.
productRequest.delegate = self
productRequest.start()
print("Fetching Products");
}
else {
print("can't make purchases")
}
}
The problem was US Tax Form and Agreement. Once its approved, everything it will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With