From 17bbe4e1a4792d3b897d30e29a2062f0c1e57910 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Fri, 4 Aug 2017 13:52:10 +0300 Subject: [PATCH] UIAlertView removed --- Classes/BITAuthenticationViewController.m | 37 +- Classes/BITAuthenticator.m | 59 +--- Classes/BITAuthenticator_Private.h | 2 +- Classes/BITCrashManager.m | 109 ++---- Classes/BITFeedbackListViewController.h | 2 +- Classes/BITFeedbackListViewController.m | 202 +++-------- Classes/BITFeedbackManager.m | 67 +--- Classes/BITFeedbackManagerPrivate.h | 2 +- Classes/BITHockeyBaseManager.m | 3 +- Classes/BITHockeyBaseManagerPrivate.h | 5 +- Classes/BITStoreUpdateManager.m | 94 ++---- Classes/BITStoreUpdateManagerPrivate.h | 2 +- Classes/BITUpdateManager.h | 2 +- Classes/BITUpdateManager.m | 393 ++++++---------------- Classes/BITUpdateManagerPrivate.h | 2 +- 15 files changed, 257 insertions(+), 724 deletions(-) diff --git a/Classes/BITAuthenticationViewController.m b/Classes/BITAuthenticationViewController.m index 8a0fb5bf9e..6c12fcc34e 100644 --- a/Classes/BITAuthenticationViewController.m +++ b/Classes/BITAuthenticationViewController.m @@ -296,35 +296,14 @@ //controller should dismiss us shortly.. } else { dispatch_async(dispatch_get_main_queue(), ^{ - - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil - message:error.localizedDescription - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"OK") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) {}]; - - [alertController addAction:okAction]; - - [self presentViewController:alertController animated:YES completion:nil]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil - message:error.localizedDescription - delegate:nil - cancelButtonTitle:BITHockeyLocalizedString(@"OK") - otherButtonTitles:nil]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil + message:error.localizedDescription + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"OK") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) {}]; + [alertController addAction:okAction]; + [self presentViewController:alertController animated:YES completion:nil]; typeof(self) strongSelf = weakSelf; [strongSelf setLoginUIEnabled:YES]; }); diff --git a/Classes/BITAuthenticator.m b/Classes/BITAuthenticator.m index 862339cdb2..8120fc22fc 100644 --- a/Classes/BITAuthenticator.m +++ b/Classes/BITAuthenticator.m @@ -241,40 +241,20 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44}; [self dismissAuthenticationControllerAnimated:YES completion:nil]; } else { BITHockeyLogError(@"Validation failed with error: %@", error); - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil - message:error.localizedDescription - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf validate]; - }]; - - [alertController addAction:okAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil - message:error.localizedDescription - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") - otherButtonTitles:nil]; - [alertView setTag:0]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ + __weak typeof(self) weakSelf = self; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil + message:error.localizedDescription + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf validate]; + }]; + + [alertController addAction:okAction]; + [self showAlertController:alertController]; } }); }]; @@ -1004,17 +984,6 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44}; } } -#pragma mark - UIAlertViewDelegate - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) __unused buttonIndex { - if (alertView.tag == 0) { - [self validate]; - } -} -#pragma clang diagnostic pop - @end #endif /* HOCKEYSDK_FEATURE_AUTHENTICATOR */ diff --git a/Classes/BITAuthenticator_Private.h b/Classes/BITAuthenticator_Private.h index ac97180b79..b0a97ea5b8 100644 --- a/Classes/BITAuthenticator_Private.h +++ b/Classes/BITAuthenticator_Private.h @@ -35,7 +35,7 @@ @class BITHockeyAppClient; -@interface BITAuthenticator () +@interface BITAuthenticator () /** Delegate that can be used to do any last minute configurations on the diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 6cc855d971..ea71c05932 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -1082,65 +1082,36 @@ __attribute__((noreturn)) static void uncaught_cxx_exception_handler(const BITCr if (self.alertViewHandler) { self.alertViewHandler(); } else { - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName] - message:alertDescription - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashDontSendReport") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - - [strongSelf handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil]; - }]; - - [alertController addAction:cancelAction]; - - UIAlertAction *sendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReport") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName] + message:alertDescription + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashDontSendReport") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) { typeof(self) strongSelf = weakSelf; - [strongSelf handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil]; + [strongSelf handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil]; }]; - - [alertController addAction:sendAction]; - - if (self.shouldShowAlwaysButton) { - UIAlertAction *alwaysSendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil]; - }]; - - [alertController addAction:alwaysSendAction]; - } - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName] - message:alertDescription - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"CrashDontSendReport") - otherButtonTitles:BITHockeyLocalizedString(@"CrashSendReport"), nil]; - - if (self.shouldShowAlwaysButton) { - [alertView addButtonWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways")]; - } - - [alertView show]; -#pragma clang diagnostic pop - /*}*/ + [alertController addAction:cancelAction]; + UIAlertAction *sendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReport") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil]; + }]; + [alertController addAction:sendAction]; + if (self.shouldShowAlwaysButton) { + UIAlertAction *alwaysSendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil]; + }]; + + [alertController addAction:alwaysSendAction]; + } + + [self showAlertController:alertController]; } #endif /* !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions) */ @@ -1552,30 +1523,6 @@ __attribute__((noreturn)) static void uncaught_cxx_exception_handler(const BITCr } } -#if !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions) - -#pragma mark - UIAlertView Delegate - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -- (void)alertView:(UIAlertView *) __unused alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - switch (buttonIndex) { - case 0: - [self handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil]; - break; - case 1: - [self handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil]; - break; - case 2: - [self handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil]; - break; - } -} -#pragma clang diagnostic pop - -#endif /* !defined (HOCKEYSDK_CONFIGURATION_ReleaseCrashOnlyExtensions) */ - - #pragma mark - Networking - (NSData *)postBodyWithXML:(NSString *)xml attachment:(BITHockeyAttachment *)attachment boundary:(NSString *)boundary { diff --git a/Classes/BITFeedbackListViewController.h b/Classes/BITFeedbackListViewController.h index 4687d38fc3..62fd91d518 100644 --- a/Classes/BITFeedbackListViewController.h +++ b/Classes/BITFeedbackListViewController.h @@ -55,7 +55,7 @@ This ensures that the presentation on iOS 6 and iOS 7 will use the current design on each OS Version. */ -@interface BITFeedbackListViewController : BITHockeyBaseViewController { +@interface BITFeedbackListViewController : BITHockeyBaseViewController { } @end diff --git a/Classes/BITFeedbackListViewController.m b/Classes/BITFeedbackListViewController.m index 454f0dd4fb..ebee74733d 100644 --- a/Classes/BITFeedbackListViewController.m +++ b/Classes/BITFeedbackListViewController.m @@ -260,69 +260,30 @@ } - (void)deleteAllMessagesAction:(id) __unused sender { - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - - NSString *title = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages"); - NSString *message = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle"); - UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert; - if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { - controllerStyle = UIAlertControllerStyleActionSheet; - title = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle"); - message = nil; - } - __weak typeof(self) weakSelf = self; - - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title - message:message - preferredStyle:controllerStyle]; - - - UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) {}]; - - [alertController addAction:cancelAction]; - - UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf deleteAllMessages]; - }]; - - [alertController addAction:deleteAction]; - - - [self presentViewController:alertController animated:YES completion:nil]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { - UIActionSheet *deleteAction = [[UIActionSheet alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle") - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel") - destructiveButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete") - otherButtonTitles:nil - ]; - [deleteAction setTag:0]; - [deleteAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; - [deleteAction showInView:[self viewForShowingActionSheetOnPhone]]; - } else { - UIAlertView *deleteAction = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages") - message:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle") - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel") - otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete"), nil]; - - [deleteAction setTag:0]; - [deleteAction show]; - } -#pragma clang diagnostic pop - /*}*/ + NSString *title = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages"); + NSString *message = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle"); + UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert; + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { + controllerStyle = UIAlertControllerStyleActionSheet; + title = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle"); + message = nil; + } + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title + message:message + preferredStyle:controllerStyle]; + UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) {}]; + [alertController addAction:cancelAction]; + UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf deleteAllMessages]; + }]; + [alertController addAction:deleteAction]; + [self presentViewController:alertController animated:YES completion:nil]; } - (UIView*) viewForShowingActionSheetOnPhone { @@ -704,98 +665,32 @@ #pragma mark - BITAttributedLabelDelegate - (void)attributedLabel:(BITAttributedLabel *) __unused label didSelectLinkWithURL:(NSURL *)url { - /* - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert; - if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { - controllerStyle = UIAlertControllerStyleActionSheet; - } - - UIAlertController *linkAction = [UIAlertController alertControllerWithTitle:[url absoluteString] - message:nil - preferredStyle:controllerStyle]; - - - UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) {}]; - - [linkAction addAction:cancelAction]; - - UIAlertAction* openAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[url absoluteString]]]; - }]; - - [linkAction addAction:openAction]; - - UIAlertAction* copyAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; - pasteboard.URL = [NSURL URLWithString:[url absoluteString]]; - }]; - - [linkAction addAction:copyAction]; - - - [self presentViewController:linkAction animated:YES completion:nil]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { - UIActionSheet *linkAction = [[UIActionSheet alloc] initWithTitle:[url absoluteString] - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel") - destructiveButtonTitle:nil - otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil - ]; - [linkAction setTag:1]; - [linkAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; - [linkAction showInView:[self viewForShowingActionSheetOnPhone]]; - } else { - UIAlertView *linkAction = [[UIAlertView alloc] initWithTitle:[url absoluteString] - message:nil - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel") - otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil - ]; - - [linkAction setTag:1]; - [linkAction show]; - } -#pragma clang diagnostic pop - /*}*/ -} - - -#pragma mark - UIAlertViewDelegate - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - if (buttonIndex == alertView.cancelButtonIndex) { - return; - } - - if ([alertView tag] == 0) { - if (buttonIndex == [alertView firstOtherButtonIndex]) { - [self deleteAllMessages]; - } - } else { - if (buttonIndex == [alertView firstOtherButtonIndex]) { - [[UIApplication sharedApplication] openURL:(NSURL *)[NSURL URLWithString:alertView.title]]; - } else { - UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; - pasteboard.URL = [NSURL URLWithString:alertView.title]; - } + UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert; + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { + controllerStyle = UIAlertControllerStyleActionSheet; } + UIAlertController *linkAction = [UIAlertController alertControllerWithTitle:[url absoluteString] + message:nil + preferredStyle:controllerStyle]; + UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) {}]; + [linkAction addAction:cancelAction]; + UIAlertAction* openAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + [[UIApplication sharedApplication] openURL:(NSURL*)[NSURL URLWithString:(NSString*)[url absoluteString]]]; + }]; + [linkAction addAction:openAction]; + UIAlertAction* copyAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + pasteboard.URL = [NSURL URLWithString:(NSString*)[url absoluteString]]; + }]; + [linkAction addAction:copyAction]; + [self presentViewController:linkAction animated:YES completion:nil]; } -#pragma clang diagnostic pop #pragma mark - UIActionSheetDelegate @@ -818,7 +713,6 @@ } } - #pragma mark - ListViewCellDelegate - (void)listCell:(id) __unused cell didSelectAttachment:(BITFeedbackMessageAttachment *)attachment { diff --git a/Classes/BITFeedbackManager.m b/Classes/BITFeedbackManager.m index db4cc5578c..996d02587d 100644 --- a/Classes/BITFeedbackManager.m +++ b/Classes/BITFeedbackManager.m @@ -832,41 +832,22 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage if (self.showAlertOnIncomingMessages && !self.currentFeedbackListViewController && !self.currentFeedbackComposeViewController) { dispatch_async(dispatch_get_main_queue(), ^{ - /* - // Requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageTitle") - message:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageText") - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageTitle") + message:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageText") + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackIgnore") + style:UIAlertActionStyleCancel + handler:nil]; + UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackShow") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused * __nonnull action) { + [self showFeedbackListView]; + }]; + [alertController addAction:cancelAction]; + [alertController addAction:showAction]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackIgnore") - style:UIAlertActionStyleCancel - handler:nil]; - UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackShow") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *__nonnull action) { - [self showFeedbackListView]; - }]; - [alertController addAction:cancelAction]; - [alertController addAction:showAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageTitle") - message:BITHockeyLocalizedString(@"HockeyFeedbackNewMessageText") - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackIgnore") - otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackShow"), nil - ]; - [alertView setTag:0]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ - self.incomingMessagesAlertShowing = YES; + [self showAlertController:alertController]; + self.incomingMessagesAlertShowing = YES; }); } } @@ -1139,24 +1120,6 @@ typedef void (^BITLatestImageFetchCompletionBlock)(UIImage *_Nonnull latestImage [self submitPendingMessages]; } - -#pragma mark - UIAlertViewDelegate - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -// invoke the selected action from the action sheet for a location element -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - - self.incomingMessagesAlertShowing = NO; - if (buttonIndex == [alertView firstOtherButtonIndex]) { - // Show button has been clicked - [self showFeedbackListView]; - } -} - -#pragma clang diagnostic pop - #pragma mark - Observation Handling - (void)setFeedbackObservationMode:(BITFeedbackObservationMode)feedbackObservationMode { diff --git a/Classes/BITFeedbackManagerPrivate.h b/Classes/BITFeedbackManagerPrivate.h index f59fe47c31..ab4bbe1935 100644 --- a/Classes/BITFeedbackManagerPrivate.h +++ b/Classes/BITFeedbackManagerPrivate.h @@ -36,7 +36,7 @@ extern NSString *const kBITFeedbackUpdateAttachmentThumbnail; @class UITapGestureRecognizer; -@interface BITFeedbackManager () { +@interface BITFeedbackManager () { } diff --git a/Classes/BITHockeyBaseManager.m b/Classes/BITHockeyBaseManager.m index 7e7537ce9d..fadd8d8753 100644 --- a/Classes/BITHockeyBaseManager.m +++ b/Classes/BITHockeyBaseManager.m @@ -216,7 +216,7 @@ return parentViewController; } -/* We won't use this for now until we have a more robust solution for displaying UIAlertController + - (void)showAlertController:(UIViewController *)alertController { // always execute this on the main thread @@ -236,7 +236,6 @@ } }); } -*/ - (void)showView:(UIViewController *)viewController { // if we compile Crash only, then BITHockeyBaseViewController is not included diff --git a/Classes/BITHockeyBaseManagerPrivate.h b/Classes/BITHockeyBaseManagerPrivate.h index 2438791932..2ddf12d92e 100644 --- a/Classes/BITHockeyBaseManagerPrivate.h +++ b/Classes/BITHockeyBaseManagerPrivate.h @@ -77,10 +77,9 @@ * * @param alertController The UIAlertController to be presented. */ -/* We won't use this for now until we have a more robust solution for displaying UIAlertController - (void)showAlertController:(UIViewController *)alertController; -*/ - - (void)showView:(UIViewController *)viewController; + +- (void)showView:(UIViewController *)viewController; #endif // Date helpers diff --git a/Classes/BITStoreUpdateManager.m b/Classes/BITStoreUpdateManager.m index 3da22aca03..02a4be9e86 100644 --- a/Classes/BITStoreUpdateManager.m +++ b/Classes/BITStoreUpdateManager.m @@ -439,59 +439,33 @@ dispatch_async(dispatch_get_main_queue(), ^{ if (!self.updateAlertShowing) { NSString *versionString = [NSString stringWithFormat:@"%@ %@", BITHockeyLocalizedString(@"UpdateVersion"), self.latestStoreVersion]; - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") - message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString] - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf ignoreAction]; - }]; - - [alertController addAction:ignoreAction]; - - UIAlertAction *remindAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateRemindMe") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf remindAction]; - }]; - - [alertController addAction:remindAction]; - - UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + __weak typeof(self) weakSelf = self; + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") + message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) { typeof(self) strongSelf = weakSelf; - [strongSelf showAction]; + [strongSelf ignoreAction]; }]; - - [alertController addAction:showAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") - message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString] - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore") - otherButtonTitles:BITHockeyLocalizedString(@"UpdateRemindMe"), BITHockeyLocalizedString(@"UpdateShow"), nil - ]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ - + [alertController addAction:ignoreAction]; + UIAlertAction *remindAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateRemindMe") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf remindAction]; + }]; + [alertController addAction:remindAction]; + UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf showAction]; + }]; + [alertController addAction:showAction]; + [self showAlertController:alertController]; self.updateAlertShowing = YES; } }); @@ -508,8 +482,6 @@ } } -#pragma mark - UIAlertViewDelegate - - (void)ignoreAction { self.updateAlertShowing = NO; [self.userDefaults setObject:self.latestStoreVersion forKey:kBITStoreUpdateIgnoreVersion]; @@ -530,22 +502,6 @@ } } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -// invoke the selected action from the action sheet for a location element -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - if (buttonIndex == [alertView cancelButtonIndex]) { - [self ignoreAction]; - } else if (buttonIndex == [alertView firstOtherButtonIndex]) { - // Remind button - [self remindAction]; - } else if (buttonIndex == [alertView firstOtherButtonIndex] + 1) { - // Show button - [self showAction]; - } -} -#pragma clang diagnostic pop - @end #endif /* HOCKEYSDK_FEATURE_STORE_UPDATES */ diff --git a/Classes/BITStoreUpdateManagerPrivate.h b/Classes/BITStoreUpdateManagerPrivate.h index c614f551ce..156913c514 100644 --- a/Classes/BITStoreUpdateManagerPrivate.h +++ b/Classes/BITStoreUpdateManagerPrivate.h @@ -31,7 +31,7 @@ #if HOCKEYSDK_FEATURE_STORE_UPDATES -@interface BITStoreUpdateManager () { +@interface BITStoreUpdateManager () { } ///----------------------------------------------------------------------------- diff --git a/Classes/BITUpdateManager.h b/Classes/BITUpdateManager.h index 36747bd82c..6bfc73318a 100644 --- a/Classes/BITUpdateManager.h +++ b/Classes/BITUpdateManager.h @@ -72,7 +72,7 @@ typedef NS_ENUM (NSUInteger, BITUpdateSetting) { */ -@interface BITUpdateManager : BITHockeyBaseManager +@interface BITUpdateManager : BITHockeyBaseManager ///----------------------------------------------------------------------------- /// @name Update Checking diff --git a/Classes/BITUpdateManager.m b/Classes/BITUpdateManager.m index c16e01aa6a..dde02ee4f2 100644 --- a/Classes/BITUpdateManager.m +++ b/Classes/BITUpdateManager.m @@ -87,34 +87,14 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { // only show error if we enable that if (self.showFeedback) { - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateError") - message:[error localizedDescription] - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [alertController addAction:okAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateError") - message:[error localizedDescription] - delegate:nil - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") - otherButtonTitles:nil]; - [alert show]; -#pragma clang diagnostic pop - /*}*/ + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateError") + message:[error localizedDescription] + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) {}]; + [alertController addAction:okAction]; + [self showAlertController:alertController]; self.showFeedback = NO; } } @@ -555,122 +535,69 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { NSString *title = BITHockeyLocalizedString(@"UpdateAvailable"); NSString *message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]]; if ([self hasNewerMandatoryVersion]) { - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - self.updateAlertShowing = NO; - if (strongSelf.blockingView) { - [strongSelf.blockingView removeFromSuperview]; - } - [strongSelf showUpdateView]; - }]; - - [alertController addAction:showAction]; - - UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - self.updateAlertShowing = NO; - (void)[strongSelf initiateAppDownload]; - }]; - - [alertController addAction:installAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title - message:message - delegate:self - cancelButtonTitle:nil - otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), BITHockeyLocalizedString(@"UpdateInstall"), nil - ]; - [alertView setTag:BITUpdateAlertViewTagMandatoryUpdate]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title + message:message + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + self.updateAlertShowing = NO; + if (strongSelf.blockingView) { + [strongSelf.blockingView removeFromSuperview]; + } + [strongSelf showUpdateView]; + }]; + [alertController addAction:showAction]; + UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + self.updateAlertShowing = NO; + (void)[strongSelf initiateAppDownload]; + }]; + [alertController addAction:installAction]; + [self showAlertController:alertController]; self.updateAlertShowing = YES; } else { message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]]; - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore") - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - self.updateAlertShowing = NO; - if ([strongSelf expiryDateReached] && !strongSelf.blockingView) { - [strongSelf alertFallback:self.blockingScreenMessage]; - } - }]; - - [alertController addAction:ignoreAction]; - - UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title + message:message + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction __unused *action) { typeof(self) strongSelf = weakSelf; self.updateAlertShowing = NO; - if (strongSelf.blockingView) { - [strongSelf.blockingView removeFromSuperview]; + if ([strongSelf expiryDateReached] && !strongSelf.blockingView) { + [strongSelf alertFallback:self.blockingScreenMessage]; } - [strongSelf showUpdateView]; - }]; - - [alertController addAction:showAction]; - - if (self.isShowingDirectInstallOption) { - UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - self.updateAlertShowing = NO; - (void)[strongSelf initiateAppDownload]; - }]; - - [alertController addAction:installAction]; - } - - [self showAlertController:alertController ]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title - message:message - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore") - otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), nil - ]; - if (self.isShowingDirectInstallOption) { - [alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateInstall")]; - } - [alertView setTag:BITUpdateAlertViewTagDefaultUpdate]; - [alertView show]; -#pragma clang diagnostic pop - /*}*/ + }]; + [alertController addAction:ignoreAction]; + UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + self.updateAlertShowing = NO; + if (strongSelf.blockingView) { + [strongSelf.blockingView removeFromSuperview]; + } + [strongSelf showUpdateView]; + }]; + [alertController addAction:showAction]; + if (self.isShowingDirectInstallOption) { + UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + self.updateAlertShowing = NO; + (void)[strongSelf initiateAppDownload]; + }]; + [alertController addAction:installAction]; + } + [self showAlertController:alertController ]; self.updateAlertShowing = YES; } } @@ -744,55 +671,27 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { // nag the user with neverending alerts if we cannot find out the window for presenting the covering sheet - (void)alertFallback:(NSString *)message { - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil - message:message - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf alertFallback:self.blockingScreenMessage]; - }]; - - [alertController addAction:okAction]; - - if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:self.blockingScreenMessage]) { - UIAlertAction *checkAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - [strongSelf checkForUpdateForExpiredVersion]; - }]; - - [alertController addAction:checkAction]; - } - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil - message:message - delegate:self - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") - otherButtonTitles:nil - ]; - - if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:self.blockingScreenMessage]) { - [alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck")]; - } - - [alertView setTag:BITUpdateAlertViewTagNeverEndingAlertView]; - [alertView show]; - /*}*/ + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil + message:message + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf alertFallback:self.blockingScreenMessage]; + }]; + [alertController addAction:okAction]; + if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:self.blockingScreenMessage]) { + UIAlertAction *checkAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + [strongSelf checkForUpdateForExpiredVersion]; + }]; + [alertController addAction:checkAction]; + } + [self showAlertController:alertController]; } #pragma mark - RequestComments @@ -915,33 +814,15 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } #if TARGET_OS_SIMULATOR - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateWarning") - message:BITHockeyLocalizedString(@"UpdateSimulatorMessage") - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [alertController addAction:okAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateWarning") - message:BITHockeyLocalizedString(@"UpdateSimulatorMessage") - delegate:nil - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") - otherButtonTitles:nil]; - [alert show]; -#pragma clang diagnostic pop - /*}*/ + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateWarning") + message:BITHockeyLocalizedString(@"UpdateSimulatorMessage") + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) {}]; + [alertController addAction:okAction]; + [self showAlertController:alertController]; return NO; #else @@ -1087,41 +968,21 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { versionString = [shortVersionString length] ? [NSString stringWithFormat:@"(%@)", versionString] : versionString; NSString *currentVersionString = [NSString stringWithFormat:@"%@ %@ %@%@", self.newestAppVersion.name, BITHockeyLocalizedString(@"UpdateVersion"), shortVersionString, versionString]; NSString *alertMsg = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableMessage"), currentVersionString]; - /* We won't use this for now until we have a more robust solution for displaying UIAlertController - // requires iOS 8 - id uialertcontrollerClass = NSClassFromString(@"UIAlertController"); - if (uialertcontrollerClass) { - __weak typeof(self) weakSelf = self; - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle") - message:alertMsg - preferredStyle:UIAlertControllerStyleAlert]; - - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - typeof(self) strongSelf = weakSelf; - self.updateAlertShowing = NO; - if ([strongSelf expiryDateReached] && !strongSelf.blockingView) { - [strongSelf alertFallback:self.blockingScreenMessage]; - } - }]; - - [alertController addAction:okAction]; - - [self showAlertController:alertController]; - } else { - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle") - message:alertMsg - delegate:nil - cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") - otherButtonTitles:nil]; - [alert show]; -#pragma clang diagnostic pop - /*}*/ + __weak typeof(self) weakSelf = self; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle") + message:alertMsg + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction __unused *action) { + typeof(self) strongSelf = weakSelf; + self.updateAlertShowing = NO; + if ([strongSelf expiryDateReached] && !strongSelf.blockingView) { + [strongSelf alertFallback:self.blockingScreenMessage]; + } + }]; + [alertController addAction:okAction]; + [self showAlertController:alertController]; } if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self hasNewerMandatoryVersion])) { @@ -1286,40 +1147,6 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) { } } - -#pragma mark - UIAlertViewDelegate - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -// invoke the selected action from the action sheet for a location element -- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - if ([alertView tag] == BITUpdateAlertViewTagNeverEndingAlertView) { - if (buttonIndex == 1) { - [self checkForUpdateForExpiredVersion]; - } else { - [self alertFallback:self.blockingScreenMessage]; - } - return; - } - - self.updateAlertShowing = NO; - if (buttonIndex == [alertView firstOtherButtonIndex]) { - // YES button has been clicked - if (self.blockingView) { - [self.blockingView removeFromSuperview]; - } - [self showUpdateView]; - } else if (buttonIndex == [alertView firstOtherButtonIndex] + 1) { - // YES button has been clicked - (void)[self initiateAppDownload]; - } else { - if ([self expiryDateReached] && !self.blockingView) { - [self alertFallback:self.blockingScreenMessage]; - } - } -} -#pragma clang diagnostic pop - @end #endif /* HOCKEYSDK_FEATURE_UPDATES */ diff --git a/Classes/BITUpdateManagerPrivate.h b/Classes/BITUpdateManagerPrivate.h index eab687497d..f578247a0a 100644 --- a/Classes/BITUpdateManagerPrivate.h +++ b/Classes/BITUpdateManagerPrivate.h @@ -88,7 +88,7 @@ - (NSURLRequest *)requestForUpdateCheck; -// initiates app-download call. displays an system UIAlertView +// initiates app-download call. displays an system UIAlertController - (BOOL)initiateAppDownload; // get/set current active hockey view controller