From d4f2c0f249fea5353ab36110ace5166b6bb2b780 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 7 Jul 2016 09:54:30 -0700 Subject: [PATCH 1/2] ensure picker source available to prevent crash This is crashing on simulator, but presumable if it weren't available for other reasons (permissions?) it would also crash. // FREEBIE --- .../view controllers/MessagesViewController.m | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index 573272bae..d2c1b145b 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -1334,29 +1334,30 @@ typedef enum : NSUInteger { */ - (void)takePictureOrVideo { - UIImagePickerController *picker = [[UIImagePickerController alloc] init]; - picker.delegate = self; - picker.allowsEditing = NO; - picker.sourceType = UIImagePickerControllerSourceTypeCamera; - - if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { - picker.mediaTypes = @[ (NSString *)kUTTypeImage, (NSString *)kUTTypeMovie ]; - [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; + if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { + DDLogError(@"Camera ImagePicker source not available"); + return; } + + UIImagePickerController *picker = [[UIImagePickerController alloc] init]; + picker.sourceType = UIImagePickerControllerSourceTypeCamera; + picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage, (__bridge NSString *)kUTTypeMovie ]; + picker.allowsEditing = NO; + picker.delegate = self; + [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; } - (void)chooseFromLibrary { - UIImagePickerController *picker = [[UIImagePickerController alloc] init]; - picker.delegate = self; - picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - - if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { - NSArray *photoOrVideoTypeArray = [[NSArray alloc] - initWithObjects:(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie, (NSString *)kUTTypeVideo, nil]; - - picker.mediaTypes = photoOrVideoTypeArray; - [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; + if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { + DDLogError(@"PhotoLibrary ImagePicker source not available"); + return; } + + UIImagePickerController *picker = [[UIImagePickerController alloc] init]; + picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + picker.delegate = self; + picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage, (__bridge NSString *)kUTTypeMovie ]; + [self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]]; } /* From 1f1920b6488797c6e3e364edfb50405b7e8ec51e Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 7 Jul 2016 10:24:10 -0700 Subject: [PATCH 2/2] Fix crash on iOS10 when attaching media New permissions strings are required. // FREEBIE --- Signal/Signal-Info.plist | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index b414037f6..fb2597ebb 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -73,6 +73,10 @@ Signal uses your contacts to find users you know. We do not store your contacts on the server. NSMicrophoneUsageDescription Signal needs access to your microphone to make and receive phone calls. + NSAppleMusicUsageDescription + Signal will let you choose which media from your library to send. + NSPhotoLibraryUsageDescription + Signal will let you choose which photos from your library to send. UIApplicationShortcutItems