简体   繁体   中英

MKStoreKit restore purchases always success

I'm trying to make a simple IAP for delete all the Ad of my app. When I buy IAP it work, but when I try to restore purchase with clear sandbox account (which have never buy the IAP), it work.

So, the restorePurchases() always work, even if the user don't have buy the IAP previously.

There is my code : When user select restore button I perform this method :

func restaureIAP() {
    PKNotification.toast("Chargement en cours...")
    MKStoreKit.sharedKit().restorePurchases()
}

I have also add observer :

// 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)")
        }

This app is available on the AppStore , and have the same problem : buy IAP work but restore purchase are always successful.

Have you any ideas ?

You may check Restored Transactions with MKStoreKitRestoredPurchasesNotification and kMKStoreKitRestoringPurchasesFailedNotification observers.

 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")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM