-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
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);
}
});
}
hjonac, lucasbento and mifi
Metadata
Metadata
Assignees
Labels
No labels