Post

Replies

Boosts

Views

Activity

Reply to Wait until transaction is finished
If you were accustomed to completion handler pattern, it would not be so difficult. You will find sample code that explains how to properly use this. I was not able to find the answer in documentation and when I create a completion handler on skpaymentqueue, it gives me errors for it not conforming to protocols. IAP Manager SKPaymentQueue - https://developer.apple.com/forums/content/attachment/2431d31f-1b9e-4266-b670-32c2e434b194
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Why is this crashing?
Ok, thanks. Here is my code designed to check if purchased/purchase and then equip the icon, and refresh. However, the part with the if runs before it can be purchased, if it is already purchased then it works fine. func setIcon(name: String) {             IconChange.setIconPurchased = false             print(name)             let app = UIApplication.shared             if #available(iOS 10.3, *) {                 if app.supportsAlternateIcons {                     checkForUnlocked(name: name)                     if IconChange.setIconPurchased == true {                         app.setAlternateIconName(name, completionHandler: { (error) in                             if error != nil {                                 print("error = \(String(describing: error?.localizedDescription))")                                 // Create new Alert                                 let dialogMessage = UIAlertController(title: "Failed to change icon", message: "There was an error changing the icon: \(error!)", preferredStyle: .alert)                                                                  // Create OK button with action handler                                 let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) - Void in                                     print("\"Failed to change icon\" alert was dismised")                                  })                                                                  //Add OK button to a dialog message                                 dialogMessage.addAction(ok)                                 // Present Alert                                 self.present(dialogMessage, animated: true, completion: nil)                             }else {                                 print("Changed Icon Sucessfully.")                                 self.iconSelected = name                                 UserDefaults.standard.setValue(name, forKey: "iconSelected")                                 IconChange.pushBack = true                                 self.navigationController?.popViewController(animated: true)                                 }                             })                         }                     }                 }             }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21