0

I have the following code to recognize when a user has made a purchase:

@objc func purchaseTapped(sender: UIButton) {
    print("Tapped") // THIS PRINTS
    
    let package = self.packagesAvailableForPurchase[sender.tag]
    
    Purchases.shared.purchasePackage(package) { (transaction, customerInfo, error, userCancelled) in
        if customerInfo?.entitlements.all["AllAccess"]?.isActive == true {
            
            print("Purchased") // THIS PRINTS
            
            // INSTANTIATE NEW VIEW CONTROLLER (NOT HAPPENING)
            let authenticationViewController = UIStoryboard(name: "Main", bundle: .main).instantiateViewController(identifier: "AuthenticationViewController")
            self.window?.rootViewController = authenticationViewController
            self.window?.makeKeyAndVisible()
        }
        else {
            print("No Access")
        }
    }
}

Is there anything I'm missing to instantiate the authenticationViewController?

Arasuvel
  • 2,971
  • 1
  • 25
  • 40
amirbt17
  • 533
  • 1
  • 4
  • 13

1 Answers1

0

Update this line

let appDelegate: AppDelegate = (UIApplication.shared.delegate as! AppDelegate)
let authenticationViewController = UIStoryboard(name: "Main", bundle: .main).instantiateViewController(identifier: "AuthenticationViewController") 
appDelegate.window?.rootViewController = authenticationViewController