我试图制作一个简单的IAP来删除我应用的所有广告。
当我购买IAP时,它可以正常工作,但是当我尝试使用明确的沙盒帐户(从未购买过IAP)进行restore
购买时,它可以正常工作。
因此,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
购买总是成功。
你有什么想法吗?
答案 0 :(得分:0)
您可以使用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")
}