iOS in app purchase - no products received

后端 未结 9 1538
感情败类
感情败类 2020-12-13 10:29

I\'m trying to add in-app purchase to my app, following the techniques described here :

Introduction to In-App Purchases in iOS 6 Tutorial

I\'ve added a prod

9条回答
  •  遥遥无期
    2020-12-13 11:31

    Answer for Swift projects with same error:

    My error was here:

    //identifiers: [String]
    let productIDs = Set(arrayLiteral: identifiers) as Set!
    let request = SKProductsRequest(productIdentifiers: productIDs)
    

    But this code will lead to an error with code = 0 message Cannot connect to iTunes Store. Let's look to the SKProductsRequest input argument type:

    SKProductsRequest(productIdentifiers: Set!)

    So, code above looks legit. But it doesn't! Swift Set is the problem, considering that in input argument we see Swift Set!

    Found the answer while iterating some IAP lesson. Here is the working code:

    let productIDs = NSSet(array: identifiers)
    let request = SKProductsRequest(productIdentifiers: productIDs as! Set)
    

    You must use NSSet for now, although Swift Set is already available and it's set as input argument type! Looks like a bug for me, I'll fire a bug.

提交回复
热议问题