Skip to content

Commit 96a5fd5

Browse files
chore: removed react-native-permissions and replaced with built-in camera permission handlers
1 parent 6473817 commit 96a5fd5

File tree

8 files changed

+11
-77
lines changed

8 files changed

+11
-77
lines changed

wallets/rn_cli_wallet/ios/Podfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ end
99

1010
# Use it to require both react-native's and this package's scripts:
1111
node_require('react-native/scripts/react_native_pods.rb')
12-
node_require('react-native-permissions/scripts/setup.rb')
1312

1413
platform :ios, min_ios_version_supported
1514
prepare_react_native_project!
1615

17-
setup_permissions([
18-
'Camera',
19-
'Notifications'
20-
])
21-
2216

2317
linkage = ENV['USE_FRAMEWORKS']
2418
if linkage != nil

wallets/rn_cli_wallet/ios/Podfile.lock

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,34 +2619,6 @@ PODS:
26192619
- ReactCommon/turbomodule/core
26202620
- SocketRocket
26212621
- Yoga
2622-
- RNPermissions (5.4.2):
2623-
- boost
2624-
- DoubleConversion
2625-
- fast_float
2626-
- fmt
2627-
- glog
2628-
- hermes-engine
2629-
- RCT-Folly
2630-
- RCT-Folly/Fabric
2631-
- RCTRequired
2632-
- RCTTypeSafety
2633-
- React-Core
2634-
- React-debug
2635-
- React-Fabric
2636-
- React-featureflags
2637-
- React-graphics
2638-
- React-ImageManager
2639-
- React-jsi
2640-
- React-NativeModulesApple
2641-
- React-RCTFabric
2642-
- React-renderercss
2643-
- React-rendererdebug
2644-
- React-utils
2645-
- ReactCodegen
2646-
- ReactCommon/turbomodule/bridging
2647-
- ReactCommon/turbomodule/core
2648-
- SocketRocket
2649-
- Yoga
26502622
- RNScreens (4.16.0):
26512623
- boost
26522624
- DoubleConversion
@@ -2890,7 +2862,6 @@ DEPENDENCIES:
28902862
- "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)"
28912863
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
28922864
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
2893-
- RNPermissions (from `../node_modules/react-native-permissions`)
28942865
- RNScreens (from `../node_modules/react-native-screens`)
28952866
- "RNSentry (from `../node_modules/@sentry/react-native`)"
28962867
- RNSVG (from `../node_modules/react-native-svg`)
@@ -3076,8 +3047,6 @@ EXTERNAL SOURCES:
30763047
:path: "../node_modules/react-native-device-info"
30773048
RNGestureHandler:
30783049
:path: "../node_modules/react-native-gesture-handler"
3079-
RNPermissions:
3080-
:path: "../node_modules/react-native-permissions"
30813050
RNScreens:
30823051
:path: "../node_modules/react-native-screens"
30833052
RNSentry:
@@ -3176,7 +3145,6 @@ SPEC CHECKSUMS:
31763145
RNCClipboard: 4b58c780f63676367640f23c8e114e9bd0cf86ac
31773146
RNDeviceInfo: bcce8752b5043a623fe3c26789679b473f705d3c
31783147
RNGestureHandler: f1dd7f92a0faa2868a919ab53bb9d66eb4ebfcf5
3179-
RNPermissions: 304745e60937128f77f79a64e342295549d829da
31803148
RNScreens: 0bbf16c074ae6bb1058a7bf2d1ae017f4306797c
31813149
RNSentry: bbaa7ef3a4b131bc947de327ed9e47a054ce0978
31823150
RNSVG: 8c0bbfa480a24b24468f1c76bd852a4aac3178e6
@@ -3185,6 +3153,6 @@ SPEC CHECKSUMS:
31853153
VisionCamera: 30b358b807324c692064f78385e9a732ce1bebfe
31863154
Yoga: edeb9900b9e5bb5b27b9a6a2d5914e4fe4033c1b
31873155

3188-
PODFILE CHECKSUM: 198cfec3fad83c0e3af1672f94f8de0ffc5f2180
3156+
PODFILE CHECKSUM: 37b3abb743131d0d701e76db155ef06d7f5954ad
31893157

31903158
COCOAPODS: 1.14.3

wallets/rn_cli_wallet/ios/RNWeb3Wallet/Debug-Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
</dict>
5959
<key>NSCameraUsageDescription</key>
6060
<string>Allow access to the camera to scan codes</string>
61-
<key>NSLocationWhenInUseUsageDescription</key>
62-
<string>Our app does not request this permission or utilize this functionality but it is included in our info.plist since our app utilizes the react-native-permissions library.</string>
6361
<key>UIBackgroundModes</key>
6462
<array>
6563
<string>fetch</string>

wallets/rn_cli_wallet/ios/RNWeb3Wallet/Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
</dict>
5959
<key>NSCameraUsageDescription</key>
6060
<string>Allow access to the camera to scan codes</string>
61-
<key>NSLocationWhenInUseUsageDescription</key>
62-
<string>Our app does not request this permission or utilize this functionality but it is included in our info.plist since our app utilizes the react-native-permissions library.</string>
6361
<key>RCTNewArchEnabled</key>
6462
<true/>
6563
<key>UIBackgroundModes</key>

wallets/rn_cli_wallet/ios/RNWeb3Wallet/Internal-Info.plist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858
</dict>
5959
<key>NSCameraUsageDescription</key>
6060
<string>Allow access to the camera to scan codes</string>
61-
<key>NSLocationWhenInUseUsageDescription</key>
62-
<string>Our app does not request this permission or utilize this functionality but it is included in our info.plist since our app utilizes the react-native-permissions library.</string>
6361
<key>UIBackgroundModes</key>
6462
<array>
6563
<string>fetch</string>

wallets/rn_cli_wallet/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"react-native-get-random-values": "1.11.0",
5454
"react-native-mmkv": "3.3.3",
5555
"react-native-modal": "14.0.0-rc.1",
56-
"react-native-permissions": "5.4.2",
5756
"react-native-quick-base64": "2.2.2",
5857
"react-native-quick-crypto": "0.7.17",
5958
"react-native-safe-area-context": "5.6.1",

wallets/rn_cli_wallet/src/screens/Scan/index.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import {useEffect, useState} from 'react';
2-
import {Platform, StyleSheet, TouchableOpacity, View, Text} from 'react-native';
1+
import {useEffect,} from 'react';
2+
import { StyleSheet, TouchableOpacity, View, Text} from 'react-native';
33

44
import {
55
Camera,
66
Code,
77
useCameraDevice,
88
useCodeScanner,
9+
useCameraPermission, // Add this
910
} from 'react-native-vision-camera';
10-
import {request, PERMISSIONS, RESULTS} from 'react-native-permissions';
1111
import {useIsFocused} from '@react-navigation/native';
1212
import {SafeAreaView} from 'react-native-safe-area-context';
1313

@@ -19,7 +19,7 @@ type Props = RootStackScreenProps<'Scan'>;
1919

2020
export default function Scan({navigation}: Props) {
2121
const device = useCameraDevice('back', {physicalDevices: ['wide-angle-camera']});
22-
const [showCamera, setShowCamera] = useState(false);
22+
const {hasPermission, requestPermission} = useCameraPermission(); // Add this
2323

2424
// 2. Only activate Camera when the app is focused and this screen is currently opened
2525
const isActive = useIsFocused();
@@ -42,16 +42,10 @@ export default function Scan({navigation}: Props) {
4242
};
4343

4444
useEffect(() => {
45-
request(
46-
Platform.OS === 'ios'
47-
? PERMISSIONS.IOS.CAMERA
48-
: PERMISSIONS.ANDROID.CAMERA,
49-
).then(result => {
50-
if (result === RESULTS.GRANTED) {
51-
setShowCamera(true);
52-
}
53-
});
54-
}, []);
45+
if (!hasPermission) {
46+
requestPermission();
47+
}
48+
}, [hasPermission, requestPermission]);
5549

5650
return (
5751
<SafeAreaView style={StyleSheet.absoluteFill}>
@@ -64,7 +58,7 @@ export default function Scan({navigation}: Props) {
6458
/>
6559
</TouchableOpacity>
6660

67-
{showCamera && device ? (
61+
{hasPermission && device ? (
6862
<Camera
6963
style={StyleSheet.absoluteFill}
7064
device={device}
@@ -78,4 +72,4 @@ export default function Scan({navigation}: Props) {
7872
)}
7973
</SafeAreaView>
8074
);
81-
}
75+
}

wallets/rn_cli_wallet/yarn.lock

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4264,7 +4264,6 @@ __metadata:
42644264
react-native-get-random-values: 1.11.0
42654265
react-native-mmkv: 3.3.3
42664266
react-native-modal: 14.0.0-rc.1
4267-
react-native-permissions: 5.4.2
42684267
react-native-quick-base64: 2.2.2
42694268
react-native-quick-crypto: 0.7.17
42704269
react-native-safe-area-context: 5.6.1
@@ -10386,20 +10385,6 @@ __metadata:
1038610385
languageName: node
1038710386
linkType: hard
1038810387

10389-
"react-native-permissions@npm:5.4.2":
10390-
version: 5.4.2
10391-
resolution: "react-native-permissions@npm:5.4.2"
10392-
peerDependencies:
10393-
react: ">=18.1.0"
10394-
react-native: ">=0.70.0"
10395-
react-native-windows: ">=0.70.0"
10396-
peerDependenciesMeta:
10397-
react-native-windows:
10398-
optional: true
10399-
checksum: fac680b7d85fb979806156d6c9f90dee9c8299b83eb9d2d82bee50aec4baa71b0f5d3cf79e8bf02345e67f77d6cb0fbfbe7e54d02b6822de0ae2e0d9323a6614
10400-
languageName: node
10401-
linkType: hard
10402-
1040310388
"react-native-quick-base64@npm:2.2.2, react-native-quick-base64@npm:^2.2.2":
1040410389
version: 2.2.2
1040510390
resolution: "react-native-quick-base64@npm:2.2.2"

0 commit comments

Comments
 (0)