add a `Login` notifications request (#4006)

zio/stable
Hailey 2024-05-13 19:51:12 -07:00 committed by GitHub
parent fce65b74ff
commit fd704bfd44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View File

@ -72,7 +72,7 @@ export function useRequestNotificationsPermission() {
const gate = useGate()
return React.useCallback(
async (context: 'StartOnboarding' | 'AfterOnboarding') => {
async (context: 'StartOnboarding' | 'AfterOnboarding' | 'Login') => {
const permissions = await Notifications.getPermissionsAsync()
if (
@ -97,6 +97,7 @@ export function useRequestNotificationsPermission() {
const res = await Notifications.requestPermissionsAsync()
logEvent('notifications:request', {
context: context,
status: res.status,
})

View File

@ -17,6 +17,7 @@ export type LogEvents = {
}
'notifications:openApp': {}
'notifications:request': {
context: 'StartOnboarding' | 'AfterOnboarding' | 'Login'
status: 'granted' | 'denied' | 'undetermined'
}
'state:background': {

View File

@ -19,6 +19,7 @@ import {cleanError} from '#/lib/strings/errors'
import {createFullHandle} from '#/lib/strings/handles'
import {logger} from '#/logger'
import {useSessionApi} from '#/state/session'
import {useRequestNotificationsPermission} from 'lib/notifications/notifications'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import {FormError} from '#/components/forms/FormError'
@ -65,6 +66,7 @@ export const LoginForm = ({
const passwordInputRef = useRef<TextInput>(null)
const {_} = useLingui()
const {login} = useSessionApi()
const requestNotificationsPermission = useRequestNotificationsPermission()
const onPressSelectService = React.useCallback(() => {
Keyboard.dismiss()
@ -111,6 +113,7 @@ export const LoginForm = ({
},
'LoginForm',
)
requestNotificationsPermission('Login')
} catch (e: any) {
const errMsg = e.toString()
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)