Skip to content

Commit

Permalink
fix: permissions prompting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwynr committed Jan 30, 2024
1 parent 9e1332c commit f5cb973
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/lib/permissions/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,24 @@ export const hasNotificationPermissions = async (requestPermissions: boolean): P
global.isRequestingPermissions = true

try {
if (Platform.OS === "android") {
const has = await check(PERMISSIONS.ANDROID.POST_NOTIFICATIONS)
if (!requestPermissions) {
const has = await notifee.getNotificationSettings()

if (has !== RESULTS.GRANTED) {
if (!requestPermissions) {
return false
}
if (![AuthorizationStatus.AUTHORIZED, AuthorizationStatus.PROVISIONAL].includes(has.authorizationStatus)) {
return false
}

return true
}

const get = await request(PERMISSIONS.ANDROID.POST_NOTIFICATIONS)
if (Platform.OS === "android") {
const notifeePermissions = await notifee.requestPermission()

if (get !== RESULTS.GRANTED) {
return false
}
if (![AuthorizationStatus.AUTHORIZED, AuthorizationStatus.PROVISIONAL].includes(notifeePermissions.authorizationStatus)) {
return false
}

return true
} else {
const notifeePermissions = await notifee.requestPermission({
carPlay: false,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SettingsScreen/SettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ export const SettingsScreen = memo(({ navigation }: { navigation: any }) => {
return
}

loadNotificationAuthorizationTimeout.current = now + 5000
loadNotificationAuthorizationTimeout.current = now + 3000

try {
const has = await hasNotificationPermissions(false)
Expand Down

0 comments on commit f5cb973

Please sign in to comment.