From d7c48578a96f4ccf69d2c8d3f42ffb6d88ce26af Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 23 May 2016 11:39:30 -0700 Subject: [PATCH] Fix invite crashing without sms (#1192) * Fixes "New Message" --> "Invite contact" exception for iPhone devices that do not support SMS messaging * fix SMS invite on empty inbox This code appears in two contexts - (1) in an empty inbox , where no other view controller is presented, and (2) in compose interface where a search controller is presented, and must first be dismissed. * only check SMS sending ability directly, (not device model) This is better because: 1. sometimes iPhones can't send SMS 2. Sometimes iPads/iPods can send SMS * correct localization key * bump build // FREEBIE --- Signal/Signal-Info.plist | 2 +- .../MessageComposeTableViewController.m | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 70c308a61..322ea111a 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 2.3.0.5 + 2.3.0.6 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/Signal/src/view controllers/MessageComposeTableViewController.m b/Signal/src/view controllers/MessageComposeTableViewController.m index 7923cf93d..e0b4b3a79 100644 --- a/Signal/src/view controllers/MessageComposeTableViewController.m +++ b/Signal/src/view controllers/MessageComposeTableViewController.m @@ -301,7 +301,7 @@ message:confirmMessage preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { DDLogDebug(@"Cancel action"); @@ -313,8 +313,7 @@ handler:^(UIAlertAction *action) { [self.searchController setActive:NO]; - UIDevice *device = [UIDevice currentDevice]; - if ([[device model] isEqualToString:@"iPhone"]) { + if ([MFMessageComposeViewController canSendText]) { MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; picker.messageComposeDelegate = self; @@ -325,7 +324,6 @@ @" https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8"]; [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; } else { - // TODO: better backup for iPods (just don't support on) UIAlertView *notPermitted = [[UIAlertView alloc] initWithTitle:@"" message:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"") @@ -342,9 +340,13 @@ self.searchController.searchBar.text = @""; //must dismiss search controller before presenting alert. - [self dismissViewControllerAnimated:YES completion:^{ + if ([self presentedViewController]) { + [self dismissViewControllerAnimated:YES completion:^{ + [self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]]; + }]; + } else { [self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]]; - }]; + } } #pragma mark - SMS Composer Delegate