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
pull/1/head
Michael Kirk 10 years ago
parent 9bacc3de78
commit d7c48578a9

@ -38,7 +38,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.3.0.5</string> <string>2.3.0.6</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LOGS_EMAIL</key> <key>LOGS_EMAIL</key>

@ -301,7 +301,7 @@
message:confirmMessage message:confirmMessage
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"")
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) { handler:^(UIAlertAction *action) {
DDLogDebug(@"Cancel action"); DDLogDebug(@"Cancel action");
@ -313,8 +313,7 @@
handler:^(UIAlertAction *action) { handler:^(UIAlertAction *action) {
[self.searchController setActive:NO]; [self.searchController setActive:NO];
UIDevice *device = [UIDevice currentDevice]; if ([MFMessageComposeViewController canSendText]) {
if ([[device model] isEqualToString:@"iPhone"]) {
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self; picker.messageComposeDelegate = self;
@ -325,7 +324,6 @@
@" https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8"]; @" https://itunes.apple.com/us/app/signal-private-messenger/id874139669?mt=8"];
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
} else { } else {
// TODO: better backup for iPods (just don't support on)
UIAlertView *notPermitted = UIAlertView *notPermitted =
[[UIAlertView alloc] initWithTitle:@"" [[UIAlertView alloc] initWithTitle:@""
message:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"") message:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"")
@ -342,9 +340,13 @@
self.searchController.searchBar.text = @""; self.searchController.searchBar.text = @"";
//must dismiss search controller before presenting alert. //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]]; [self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]];
}]; }
} }
#pragma mark - SMS Composer Delegate #pragma mark - SMS Composer Delegate

Loading…
Cancel
Save