Reputation: 1605
I am trying to integrate In-App Purchases in my project. I have used a third party library, SwiftyStoreKit
, as IAP helper.
I'm trying to fetch the information of my In-App products, but always get a response that Invalid Product Identifiers
All my agreements are in Effect (Paid and Free).
Also, My In-App Product status shows Waiting for Upload
. My App is yet to be release, so I'm testing it in Sandbox Mode.
Following in my code:
import UIKit
import StoreKit
import SwiftyStoreKit
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ _animated: Bool) {
super.viewDidAppear(_animated)
if dataModel.lists.count >= 2 {
getInfo()
}
}
func getInfo() {
NetworkActivityIndicatorManager.NetworkOperationStarted()
SwiftyStoreKit.retrieveProductsInfo([productIdentifier], completion: { result in
NetworkActivityIndicatorManager.networkOperationFinished()
self.showAlert(alert: self.alertForProductRetrievalInfo(result: result))
})
}
Upvotes: 9
Views: 14090
Reputation: 783
Try use productid instead of com.yourname.projectname.productid
Upvotes: 1
Reputation: 2354
Make sure you add the "In-App Purchase" to your project from Xcode - Target - Signing & Capabilities.
Upvotes: 3
Reputation: 61774
Remember to make your In-App Ready To Submit
status.
If your In-App has different status, then it always return invalid product identifier
.
Upvotes: 1
Reputation: 966
I had the same exact problem, but the solutions above did not work for me.
This is what did:
It turns out I hadn't filled out the proper payments and W9 form on AppStoreConnect.
Go to AppStoreConnect > Agreements, Tax, and Banking...
Fill out the "Paid Apps" contract if it hadn't already been filled out
Upvotes: 27
Reputation:
This is what worked for me:
I was confusing the reference name ( left side ) with the Product ID ( right side )
So make sure that you're using iTunes Connect's Product ID in your code.
Upvotes: 4
Reputation: 589
I had the exact same error and running this code in the app delegate seemed to fix my problem because by adding your app's observer at launch ensures that it will persist during all launches of your app, thus allowing your app to receive all the payment queue notifications.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// see notes below for the meaning of Atomic / Non-Atomic
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
for purchase in purchases {
switch purchase.transaction.transactionState {
case .purchased, .restored:
if purchase.needsFinishTransaction {
// Deliver content from server, then:
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
// Unlock content
case .failed, .purchasing, .deferred:
break // do nothing
}
}
}
return true
}
Upvotes: 2
Reputation: 681
Check your productIdentifier
!
It should be the same string as registered in iTunes Connect.
E.g "com.myapp.myPurchase"
Upvotes: 7