Browse Source

Return no supported permissions for platforms other than iOS / android

Mathieu Acthernoene 5 years ago
parent
commit
df3addd630
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      src/index.ts

+ 7
- 5
src/index.ts View File

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`);
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
 function isPlatformPermission(permission: Permission): boolean {
138
 function isPlatformPermission(permission: Permission): boolean {
137
   if (platformPermissions.includes(permission)) {
139
   if (platformPermissions.includes(permission)) {
158
     return RESULTS.UNAVAILABLE;
160
     return RESULTS.UNAVAILABLE;
159
   }
161
   }
160
 
162
 
161
-  if (Platform.OS !== 'android') {
163
+  if (Platform.OS === 'ios') {
162
     return RNPermissions.check(permission);
164
     return RNPermissions.check(permission);
163
   }
165
   }
164
 
166
 
194
     return RESULTS.UNAVAILABLE;
196
     return RESULTS.UNAVAILABLE;
195
   }
197
   }
196
 
198
 
197
-  if (Platform.OS !== 'android') {
199
+  if (Platform.OS === 'ios') {
198
     return RNPermissions.request(permission);
200
     return RNPermissions.request(permission);
199
   }
201
   }
200
 
202