This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 425
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Xcode warning: UIAlertView is deprecated #264
Copy link
Copy link
Open
Description
UIAlertView is deprecated in iOS 8.0, as it's superseded by UIAlertController.
Hence changed the code in 'initiatePaymentRequestForProductWithIdentifier:' to switch between UIAlertView and UIAlertController in case the latter exists. Also suppressed the deprecation warning for UIAlertView:
if (![SKPaymentQueue canMakePayments]) {
#if TARGET_OS_IPHONE
if ([UIAlertController class]) {
// iOS 8.0+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"In App Purchasing Disabled", @"")
message:NSLocalizedString(@"Check your parental control settings and try again later", @"")
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Okay", @"")
style:UIAlertActionStyleCancel
handler:nil];
[alert addAction:cancelAction];
// Show Alert:
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert
animated:YES
completion:nil];
}
else {
// Before iOS 8.0:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"In App Purchasing Disabled", @"")
message:NSLocalizedString(@"Check your parental control settings and try again later", @"")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Okay", @"")
otherButtonTitles:nil] show];
#pragma clang diagnostic pop
}
#elif TARGET_OS_MAC
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = NSLocalizedString(@"In App Purchasing Disabled", @"");
alert.informativeText = NSLocalizedString(@"Check your parental control settings and try again later", @"");
[alert runModal];
#endif
return;
}
Metadata
Metadata
Assignees
Labels
No labels