Skip to content

Commit

Permalink
compose: Offer video capture on iOS
Browse files Browse the repository at this point in the history
Thanks to the recent upgrade of react-native-image-picker, which had
a small change to support 'mixed' in `launchCamera`:
  react-native-image-picker/react-native-image-picker@4de5e5a39
If we end up having to revert that upgrade because of something
unrelated, that change should be easy to patch in with
`patch-package`; see b546b07 for an example of using
patch-package.

Fixes: zulip#5733
  • Loading branch information
chrisbobbe authored and gnprice committed Aug 18, 2023
1 parent d026153 commit 8f2864a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ios/ZulipMobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<string>By allowing camera access, you can take photos and send them in Zulip messages.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>By allowing microphone access, you can take videos and send them in Zulip messages.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Save photos you choose from Zulip to your photo library.</string>
<key>NSPhotoLibraryUsageDescription</key>
Expand Down
20 changes: 19 additions & 1 deletion src/compose/ComposeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,25 @@ export default function ComposeMenu(props: Props): Node {

launchCamera(
{
mediaType: 'photo',
// Here's how iOS video recording works in an attempt on iOS 16:
// - iOS gives a native interface with a camera preview. You can
// choose "photo" or "video", with "photo" selected by default.
// - On tapping "video" for the first time, it shows a permissions
// prompt with the NSMicrophoneUsageDescription string. (If we
// didn't declare that string, the app would hang here.)
// - If you grant the permission, the interaction proceeds as
// you'd hope: you take a video (or cancel), then confirm,
// retake, or cancel.
// - If you don't grant the permission, it proceeds similarly,
// except the sent video will have no sound. Later interactions
// will also let you take video without sound, and you won't get
// prompted about permissions (!). If you want to record videos
// with sound, you have to look in Settings by yourself and
// grant the permission there.
//
// 'mixed' is not supported on Android:
// https://github.com/react-native-image-picker/react-native-image-picker#options
mediaType: Platform.OS === 'ios' ? 'mixed' : 'photo',

// On Android ≤9 (see above) and on iOS, this means putting up a
// scary permission request. Shrug, because other apps seem to save
Expand Down

0 comments on commit 8f2864a

Please sign in to comment.