Last active
December 30, 2020 17:29
-
-
Save sudomann/a2225ccd1e1f855af63870f5303aedfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isEnabled = async () => { | |
console.log("isEnabled() running"); | |
return SecureStore.getItemAsync(this._storageKey) | |
.then((value) => { | |
// no previously stored/specified value | |
if (value === null) Promise.reject(); | |
return value === BooleanSetting.States.ON; | |
}) | |
.catch(() => { | |
console.error("boolean seting isEnabled throwing :("); | |
return this._defaultState === BooleanSetting.States.ON; | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const refreshAbilities = async () => { | |
try { | |
const [ | |
{ granted, canAskAgain }, | |
contactUsageSettingEnabled, | |
] = await Promise.all([ | |
Contacts.getPermissionsAsync(), | |
settings.syncContacts.isEnabled(), | |
]).catch((err) => console.log('some error:', err)); | |
if (!contactUsageSettingEnabled) return; | |
if (!canAskAgain) { | |
// ... | |
return; | |
} | |
if (!granted) { | |
// ... | |
return; | |
} | |
// ... | |
); | |
} catch (err) { | |
console.error('some error', err); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment