Lack of restore function for in-app purchase causes rejection

254 Views Asked by At

I hope this will not be ignored due to some answers that exist out there. I did not see any Xcode answers. I am a new developer in the app field and Xcode is what I have learned. My question:

Are there any Xcode answers for solving the restore function problem in my app?

I have a non-consumable in-app purchase which is required by apple to provide a restore function. I need the Xcode/Swift version.

Here is the purchase code in AppDelegate (notice it is Parse version):

import UIKit import Parse import Bolts

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Parse.enableLocalDatastore()

    // Initialize Parse
    Parse.setApplicationId("supplied AppID from Parse", clientKey: "supplied Key from Parse")

    // Track statistics around application
    PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)

    PFPurchase.addObserverForProduct("REDI_REF_Mobil_Upgrade", block: { (transaction: SKPaymentTransaction!) -> Void in

        let userDefaults = NSUserDefaults.standardUserDefaults()

        userDefaults.setBool(true, forKey: "upgrade")

        userDefaults.synchronize()

    })

    return true
}

Now code from the main Upgrade button (purchase):

@IBAction func UpgradeButton(sender: UIButton) {

    PFPurchase.buyProduct("REDI_REF_Mobil_Upgrade", block: { (error:NSError?) -> Void in
    if error != nil {

        let alert = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: UIAlertControllerStyle.Alert)

        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))

        self.presentViewController(alert, animated: true, completion: nil)
        }

    })

}

I would like to add the restore as a part of the 'Upgrade' button.

1

There are 1 best solutions below

3
On

I'm not 100% sure what you were looking for, but asking like this usually won't end up well here on SO in my experience. (You'd need at least some code, or google results, not just asking for code.)

You might want to have a look at: Restore already bought in-app-purchases on iPhone?