Selaa lähdekoodia

Return no supported permissions for platforms other than iOS / android

Mathieu Acthernoene 5 vuotta sitten
vanhempi
commit
df3addd630
1 muutettua tiedostoa jossa 7 lisäystä ja 5 poistoa
  1. 7
    5
      src/index.ts

+ 7
- 5
src/index.ts Näytä tiedosto

@@ -129,9 +129,11 @@ if (RNPermissions == null) {
129 129
 If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-permissions`);
130 130
 }
131 131
 
132
-const platformPermissions = Object.values(
133
-  Platform.OS === 'ios' ? IOS : ANDROID,
134
-);
132
+const platformPermissions = Platform.select<Permission[]>({
133
+  ios: Object.values(IOS),
134
+  android: Object.values(ANDROID),
135
+  default: [],
136
+});
135 137
 
136 138
 function isPlatformPermission(permission: Permission): boolean {
137 139
   if (platformPermissions.includes(permission)) {
@@ -158,7 +160,7 @@ export async function check(permission: Permission): Promise<PermissionStatus> {
158 160
     return RESULTS.UNAVAILABLE;
159 161
   }
160 162
 
161
-  if (Platform.OS !== 'android') {
163
+  if (Platform.OS === 'ios') {
162 164
     return RNPermissions.check(permission);
163 165
   }
164 166
 
@@ -194,7 +196,7 @@ export async function request(
194 196
     return RESULTS.UNAVAILABLE;
195 197
   }
196 198
 
197
-  if (Platform.OS !== 'android') {
199
+  if (Platform.OS === 'ios') {
198 200
     return RNPermissions.request(permission);
199 201
   }
200 202