react-native-android-open-settings
react-native-android-open-settings copied to clipboard
Return promises?
Sometimes is useful to be able to run some code after you return from settings. Currently have a JavaScript helper I was using based on AppState. Not sure if there is a better 'native' way to do this, but happy to make PR to wrap the exported functions or include as a helper if this is useful to anyone. Thanks for lib!
e.g.
openDroidSetting(AndroidOpenSettings.appDetailsSettings).then(() => {
// back from settings!
// re-check permission and do stuff..
});
function openDroidSetting(settingFunc) {
return new Promise((resolve, reject) => {
const listener = (state) => {
if (state === 'active') {
AppState.removeEventListener('change', listener);
resolve();
}
};
AppState.addEventListener('change', listener);
try {
settingFunc();
}
catch (e) {
AppState.removeEventListener('change', listener);
reject(e);
}
});
}
same issue, did you find solution?
I put in a merge request #16 but I think this may be abandoned. I built an async version of this and published it under react-native-android-open-settings-async https://github.com/chris-shaw-2011/react-native-android-open-settings-async