我试图做一个简单的IAP删除我的应用程序的所有广告。当我购买IAP时,它可以工作,但是当我尝试使用restore使用明确的沙箱帐户(它从来没有购买IAP)时,它就能工作。
因此,restorePurchases()总是有效的,即使用户以前没有购买IAP。
这是我的代码:当用户选择还原按钮时,我执行以下方法:
func restaureIAP() {
PKNotification.toast("Chargement en cours...")
MKStoreKit.sharedKit().restorePurchases()
}我还增加了观察员:
// Product restaure
NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoredPurchasesNotification,
object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
PKNotification.success("Restauré !")
print ("Succes restaure: \(note.object)")
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isPurchase")
}
NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoringPurchasesFailedNotification,
object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
PKNotification.failed("Erreur")
print ("Failed restaure: \(note.object)")
}这个应用程序可以在AppStore上使用,并有同样的问题:购买IAP工作,但restore购买总是成功的。
你有什么想法吗?
发布于 2016-02-01 11:40:59
您可以使用MKStoreKitRestoredPurchasesNotification和kMKStoreKitRestoringPurchasesFailedNotification观察者检查还原的事务。
MKStoreKit.sharedKit().startProductRequest()
NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoredPurchasesNotification,
object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
print ("Restored product: \(note.object)")
}
NSNotificationCenter.defaultCenter().addObserverForName(kMKStoreKitRestoringPurchasesFailedNotification,
object: nil, queue: NSOperationQueue.mainQueue()) { (note) -> Void in
print ("Restored failed")
}https://stackoverflow.com/questions/35115207
复制相似问题