So I'm working on an in app purchase in a SpriteKit game on AppleTV, but in the event of an error with payment or any other variety of errors, I want to display an error. UIAlertView is how I did it on iOS, but that's not an option on tvOS. Is there something similar that could be done instead? Basically, I need something to popup describing the error and a button to dismiss the popup. The ability to add more buttons (like UIAlertView) would be icing.
Note: I have researched this a bit and most things seem to point to using TVML, however, I don't believe that's an option mixed in with SpriteKit. I'll accept an answer related to this if it explains how to import something TVML (which I know next to nothing about) and run it alongside SpriteKit. I assume I'm looking for an answer unrelated to TVML though.
Check tvOS UIAlertController class :
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
message:@"This is an alert."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
Edit : When using SpriteKit, last line is to replace with
UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
[controller presentViewController:alert animated:YES completion:nil];
Note that this class is also available in iOS since iOS 8 !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With