瀏覽代碼

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

+ 2
- 0
ios/Podfile 查看文件

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

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

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

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

12763
       "version": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
12763
       "version": "github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9",
12764
       "from": "react-native-locale-detector@github:jitsi/react-native-locale-detector#845281e9fd4af756f6d0f64afe5cce08c63e5ee9"
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
     "react-native-prompt": {
12771
     "react-native-prompt": {
12767
       "version": "1.0.0",
12772
       "version": "1.0.0",
12768
       "resolved": "https://registry.npmjs.org/react-native-prompt/-/react-native-prompt-1.0.0.tgz",
12773
       "resolved": "https://registry.npmjs.org/react-native-prompt/-/react-native-prompt-1.0.0.tgz",

+ 1
- 0
package.json 查看文件

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

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

8
     TouchableOpacity,
8
     TouchableOpacity,
9
     View
9
     View
10
 } from 'react-native';
10
 } from 'react-native';
11
+import Permissions from 'react-native-permissions';
11
 import { connect } from 'react-redux';
12
 import { connect } from 'react-redux';
12
 
13
 
13
 import { translate } from '../../base/i18n';
14
 import { translate } from '../../base/i18n';
59
     /**
60
     /**
60
      * Implements React's {@link Component#componentWillMount()}. Invoked
61
      * Implements React's {@link Component#componentWillMount()}. Invoked
61
      * immediately before mounting occurs. Creates a local video track if none
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
      * @inheritdoc
65
      * @inheritdoc
65
      * @returns {void}
66
      * @returns {void}
72
         if (this.props._settings.startAudioOnly) {
73
         if (this.props._settings.startAudioOnly) {
73
             dispatch(destroyLocalTracks());
74
             dispatch(destroyLocalTracks());
74
         } else {
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
 

Loading…
取消
儲存