IOS - In-App Purchase - Invalid Product ID
I am trying to integrate In-App purchases into my project. I used a third party library SwiftyStoreKit
like IAP helper.
I am trying to get information about my In-App products but I always get the answer that Invalid Product Identifiers
All my agreements are in Effect (Paid and Free). In addition, the status of My In-App Product is displayed Waiting for Upload
. My app hasn't been released yet, 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))
})
}
source to share
I had the same error and running this code in the app delegate seemed to solve my problem because adding the app browser at startup ensures that it persists across all app launches, allowing your app to receive all queue notifications payments,
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
}
source to share