我正在尝试制作一个简单的 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
购买总是成功。
你有什么想法吗?