[Android] Fix crash if settings activity cannot be opened

The documentation states this is possible, so make sure we handle such errors.

Ref:
https://developer.android.com/reference/android/provider/Settings.html#ACTION_APPLICATION_DETAILS_SETTINGS
This commit is contained in:
Saúl Ibarra Corretgé
2018-01-09 13:12:53 -06:00
committed by Paweł Domas
parent a3cb081609
commit 292f3ab1bd
2 changed files with 22 additions and 3 deletions
@@ -80,7 +80,15 @@ function _alertPermissionErrorWithSettings(trackType) {
function _openSettings() {
switch (Platform.OS) {
case 'android':
NativeModules.AndroidSettings.open();
NativeModules.AndroidSettings.open().catch(() => {
Alert.alert(
'Error opening settings',
'Please open settings and grant the required permissions',
[
{ text: 'OK' }
]
);
});
break;
case 'ios':