Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In App Purchase invalidProductIdentifier in 30% times why ?

I've configured IAP for my project and It seems to work, so my app is live on app store but I've discovered that approximately 30% requests to iTunes returning invalidProductIdentifier for some reason, below is the complete code:

class IAP: NSObject, SKProductsRequestDelegate {

    static let sharedInstance = IAP()

    func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
        response.invalidProductIdentifiers.forEach() { id in
            //here is the part that could fail sometimes
            print(id)
        }
    }

    //here how I setup IAP
    func canMakePayments() {
        if(SKPaymentQueue.canMakePayments()) {
            var productID = NSSet()
            productID = NSSet(object: "unlock")
            let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
            request.delegate = self
            request.start()
        }
    }
}

And here how I use it from AppDelegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        IAP.sharedInstance.canMakePayments()
        return true
    }
like image 218
Діма Комар Avatar asked Aug 15 '16 19:08

Діма Комар


2 Answers

If you receive invalidProductIdentifiers on your test device there may be tons of reasons why this happens. The most frequent cases are:

  • app was not reinstalled from scratch before checking: you need to delete app from device and install it again;
  • old product IDs: if you have product IDs that are invalid, they will appear in invalidProductIdentifiers;
  • jailbroken device: remove AppSync from Cydia to debug on jailbroken device;
  • using provisioning profile that is not associated with explicit App ID.

You can find more reasons here. Nevertheless invalid product IDs issue on test device doesn't necessary mean that your users experience that problem too.

like image 142
Terry Avatar answered Nov 19 '22 20:11

Terry


If you have appstore version of that application in your test device and you are trying to debug that IAP on same device, this may cause this. Please un-install apstore version of app before trying anything. Second possible problem is, you should check IAP with USB cable plugged in. You cant test it with Ad-hoc deployment.

Also I found a great link to check all possible failures:

http://troybrant.net/blog/2010/01/invalid-product-ids/

like image 1
batgun Avatar answered Nov 19 '22 20:11

batgun