I have this modal view controller that pops up when I press a button in my view controller. When that modal view controller pops up Im doing some code where the user is purchasing an item and once its dismissed I want the first view controller to know that its back in view. How would I do that? I tried to use viewDidAppear and viewWillAppear and it didn’t work.

//Goes to modal view controller

@IBAction func showIAP(_ sender: Any) {

let vc:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "InAppPurchasesViewController") as UIViewController
self.showDetailViewController(vc as! InAppPurchasesViewController, sender: self)

//Modal View Controller
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    for transaction in transactions {
        switch transaction.transactionState {

        case .purchasing:
            print("Customer is purchasing")
        case .purchased:

            UserDefaults.standard.set(true, forKey: "Made")
            self.dismiss(animated: true, completion: nil)
            print("Customer has finished purchasing")
        case .failed:

            print("The purchase has failed")

        case .restored:
            print("Restored purchase product")

        case .deferred:

         default: break


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *