浏览代码

[RN] Don't request camera permission on first launch

It will only be requested if a user joins a meeting or flips the switch from
video to audio and back, but never as the first thing when the welcome page is
mounted.
master
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
3154c6f936
共有 6 个文件被更改,包括 25 次插入3 次删除
  1. 1
    0
      .flowconfig
  2. 2
    0
      ios/Podfile
  3. 7
    1
      ios/Podfile.lock
  4. 5
    0
      package-lock.json
  5. 1
    0
      package.json
  6. 9
    2
      react/features/welcome/components/WelcomePage.native.js

+ 1
- 0
.flowconfig 查看文件

@@ -23,6 +23,7 @@
23 23
 ; seen to cause errors and we have chosen not to fix.
24 24
 .*/node_modules/@atlaskit/.*/*.js.flow
25 25
 .*/node_modules/react-native-keep-awake/.*
26
+.*/node_modules/react-native-permissions/.*
26 27
 .*/node_modules/styled-components/.*
27 28
 
28 29
 .*/\.git/.*

+ 2
- 0
ios/Podfile 查看文件

@@ -35,6 +35,8 @@ target 'JitsiMeet' do
35 35
   pod 'react-native-locale-detector',
36 36
     :path => '../node_modules/react-native-locale-detector'
37 37
   pod 'react-native-webrtc', :path => '../node_modules/react-native-webrtc'
38
+  pod 'ReactNativePermissions',
39
+    :path => '../node_modules/react-native-permissions'
38 40
   pod 'RNSound', :path => '../node_modules/react-native-sound'
39 41
   pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
40 42
   pod 'react-native-calendar-events',

+ 7
- 1
ios/Podfile.lock 查看文件

@@ -59,6 +59,8 @@ PODS:
59 59
     - React/Core
60 60
     - React/fishhook
61 61
     - React/RCTBlob
62
+  - ReactNativePermissions (1.1.1):
63
+    - React
62 64
   - RNSound (0.10.9):
63 65
     - React/Core
64 66
     - RNSound/Core (= 0.10.9)
@@ -88,6 +90,7 @@ DEPENDENCIES:
88 90
   - React/RCTNetwork (from `../node_modules/react-native`)
89 91
   - React/RCTText (from `../node_modules/react-native`)
90 92
   - React/RCTWebSocket (from `../node_modules/react-native`)
93
+  - ReactNativePermissions (from `../node_modules/react-native-permissions`)
91 94
   - RNSound (from `../node_modules/react-native-sound`)
92 95
   - RNVectorIcons (from `../node_modules/react-native-vector-icons`)
93 96
   - yoga (from `../node_modules/react-native/ReactCommon/yoga`)
@@ -117,6 +120,8 @@ EXTERNAL SOURCES:
117 120
     :path: "../node_modules/react-native-locale-detector"
118 121
   react-native-webrtc:
119 122
     :path: "../node_modules/react-native-webrtc"
123
+  ReactNativePermissions:
124
+    :path: "../node_modules/react-native-permissions"
120 125
   RNSound:
121 126
     :path: "../node_modules/react-native-sound"
122 127
   RNVectorIcons:
@@ -136,10 +141,11 @@ SPEC CHECKSUMS:
136 141
   react-native-keep-awake: 0de4bd66de0c23178107dce0c2fcc3354b2a8e94
137 142
   react-native-locale-detector: d1b2c6fe5abb56e3a1efb6c2d6f308c05c4251f1
138 143
   react-native-webrtc: 31b6d3f1e3e2ce373aa43fd682b04367250f807d
144
+  ReactNativePermissions: 9f2d9c45c98800795e6c2ed330e25d11a66a8169
139 145
   RNSound: b360b3862d3118ed1c74bb9825696b5957686ac4
140 146
   RNVectorIcons: c0dbfbf6068fefa240c37b0f71bd03b45dddac44
141 147
   yoga: a23273df0088bf7f2bb7e5d7b00044ea57a2a54a
142 148
 
143
-PODFILE CHECKSUM: fb12a5ae406b901e95aeb1ab5ebbb02773c46ede
149
+PODFILE CHECKSUM: e24d0131e937934fbe4d1f0b7ad5947ee0192f58
144 150
 
145 151
 COCOAPODS: 1.5.3

+ 5
- 0
package-lock.json 查看文件

@@ -12763,6 +12763,11 @@
12763 12763
       "version": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
12764 12764
       "from": "react-native-locale-detector@github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9"
12765 12765
     },
12766
+    "react-native-permissions": {
12767
+      "version": "1.1.1",
12768
+      "resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-1.1.1.tgz",
12769
+      "integrity": "sha512-t0Ujm177bagjUOSzhpmkSz+LqFW04HnY9TeZFavDCmV521fQvFz82aD+POXqWsAdsJVOK3umJYBNNqCjC3g0hQ=="
12770
+    },
12766 12771
     "react-native-prompt": {
12767 12772
       "version": "1.0.0",
12768 12773
       "resolved": "https://registry.npmjs.org/react-native-prompt/-/react-native-prompt-1.0.0.tgz",

+ 1
- 0
package.json 查看文件

@@ -65,6 +65,7 @@
65 65
     "react-native-keep-awake": "2.0.6",
66 66
     "react-native-linear-gradient": "2.4.0",
67 67
     "react-native-locale-detector": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
68
+    "react-native-permissions": "1.1.1",
68 69
     "react-native-prompt": "1.0.0",
69 70
     "react-native-sound": "0.10.9",
70 71
     "react-native-vector-icons": "4.4.2",

+ 9
- 2
react/features/welcome/components/WelcomePage.native.js 查看文件

@@ -8,6 +8,7 @@ import {
8 8
     TouchableOpacity,
9 9
     View
10 10
 } from 'react-native';
11
+import Permissions from 'react-native-permissions';
11 12
 import { connect } from 'react-redux';
12 13
 
13 14
 import { translate } from '../../base/i18n';
@@ -59,7 +60,7 @@ class WelcomePage extends AbstractWelcomePage {
59 60
     /**
60 61
      * Implements React's {@link Component#componentWillMount()}. Invoked
61 62
      * immediately before mounting occurs. Creates a local video track if none
62
-     * is available.
63
+     * is available and the camera permission was already granted.
63 64
      *
64 65
      * @inheritdoc
65 66
      * @returns {void}
@@ -72,7 +73,13 @@ class WelcomePage extends AbstractWelcomePage {
72 73
         if (this.props._settings.startAudioOnly) {
73 74
             dispatch(destroyLocalTracks());
74 75
         } else {
75
-            dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
76
+            // Make sure we don't request the permission for the camera from
77
+            // the start. We will, however, create a video track iff the user
78
+            // already granted the permission.
79
+            Permissions.check('camera').then(response => {
80
+                response === 'authorized'
81
+                    && dispatch(createDesiredLocalTracks(MEDIA_TYPE.VIDEO));
82
+            });
76 83
         }
77 84
     }
78 85
 

正在加载...
取消
保存