FlorianG
FlorianG

Reputation: 77

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 ?

Upvotes: 0

Views: 575

Answers (1)

Rahul Patel
Rahul Patel

Reputation: 5886

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

Upvotes: 0

Related Questions