I have a button which purchases a product which should hide the background view shielding the user from the using the extension to the app. When the button is pressed, the code to buy the product is from an external file. Because of this, I have know way of hiding the view when the purchase comes back successful.
Code from other file
for transaction: AnyObject in transactions {
if let trans: SKPaymentTransaction = transaction as? SKPaymentTransaction {
switch trans.transactionState {
case .purchased:
print("Product Purchased")
let purchased = UserDefaults.standard.bool(forKey:
"Analytics")
UserDefaults.standard.set(true, forKey: "Analytics")
Is it possible to call a function to a view controller class from an external swift file? What other way could you approach the problem?