Sorry my bad, I was going quickly and didn't clarify. This function is running and immediately after, the array that is appended with a joke is cleared and set to nil.
Post
Replies
Boosts
Views
Activity
Sorry my bad, I was going quickly and didn't clarify. This function is running and immediately after, the array that is appended with a joke is cleared and set to nil.
You need at least 41 gb of storage
Thank you so much. Will check out the tutorial.
I got what I wanted to do by posting to the Notification center when I am done with it.
Somewhat, I followed some YouTube tutorials. I understand that the purchasing state is while it is being purchased, and I understand failed, purchased, and restored. I just don't know where this fits into it.
IDK? That is what I am trying trying to figure out. Once I figure that out. It is much easier.
IAP Manager.Swift - https://developer.apple.com/forums/content/attachment/1ab567f7-538a-4a78-a9c7-79ebf3f334a4
After the transaction has taken place. I want to trigger the transaction, and then run an if sentence after that. However, it runs before. Therefore, I need to figure out how to do call completion after the transaction.
So then, how do I write completion in the correct place?
The thing is, there is no error, it just calls completion() too early.
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
Once an icon gets purchased, setIconPurchased gets set to true, and then if it equals true it does more actions.
Would you like me to give you my project so you can run it? The if I am talking about is on line 15 and it is supposed to prompt to get purchased if not purchased already, and then refresh and select it. However, the if on line 15 is running before you purchase it.
Thank you for all the help you two!
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)
}
})
}
}
}
}
Ok, but I am still wondering about how to get the things to trigger if setIconPurchased = true